/** @packageDocumentation * @module CartesianGeometry */ import { AngleSweepProps, BeJSONFunctions } from "../Geometry"; import { Angle } from "./Angle"; import { GrowableFloat64Array } from "./GrowableFloat64Array"; /** * Selector for how to convert an angle outside of a sweep to an exterior fraction. * @see [[AngleSweep.radiansToSignedPeriodicFractionStartEnd]], [[AngleSweep.angleToSignedPeriodicFraction]], [[AngleSweep.radiansToSignedPeriodicFraction]] * @public */ export declare enum ExteriorFractionSelector { /** Request [[Positive]] or [[Negative]] based on input sign. */ SameSign = -1, /** Request positive exterior fraction within one period of 1. */ Positive = 0, /** Request negative exterior fraction within one period of 0. */ Negative = 1, /** Request the period-shifted exterior fraction closest to [0,1]. */ Closer = 2 } /** * An `AngleSweep` is a pair of angles at start and end of an interval. * * * For stroking purposes, the "included interval" is all angles numerically reached * by `theta = start + f * (end - start)`, where `0 <= f <= 1`. * * This stroking formula is simple numbers -- 2PI shifts are not involved. * * 2PI shifts do become important in the reverse mapping of an angle to a fraction. * * Angles greater than 360 and less than 0 are fine as endpoints. * * An AngleSweep determines orientation only _in concert with a reference vector_, e.g., a plane normal like (0,0,1). * * Be careful reading orientation from an AngleSweep without a reference vector! * * If "start < end" the angles in the sweep proceed counterclockwise around the reference vector. * * If "start > end" the angles in the sweep proceed clockwise around the reference vector. * * (350,370) covers the same angles as (-10,10), and both sweeps are counterclockwise around the reference vector. * * (370,350) covers the same angles as (10,-10), and both sweeps are clockwise around the reference vector. * * (370,350) covers the same angles as (-10,10), but the sweeps have opposite orientation. * * Math details can be found at docs/learning/geometry/Angle.md . * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/AngleSweep . * @public */ export declare class AngleSweep implements BeJSONFunctions { private _radians0; private _radians1; /** Read-property for degrees at the start of this AngleSweep. */ get startDegrees(): number; /** Read-property for degrees at the end of this AngleSweep. */ get endDegrees(): number; /** Read-property for signed start-to-end sweep in degrees. */ get sweepDegrees(): number; /** Read-property for degrees at the start of this AngleSweep. */ get startRadians(): number; /** Read-property for degrees at the end of this AngleSweep. */ get endRadians(): number; /** Read-property for signed start-to-end sweep in radians. */ get sweepRadians(): number; /** Whether the sweep angles are within smallAngle tolerance, without period shift. */ get isEmpty(): boolean; /** Return the (strongly typed) start angle */ get startAngle(): Angle; /** Return the (strongly typed) end angle */ get endAngle(): Angle; /** * Create a sweep as one of * * A clone of a given sweep * * 0 to given angle * * full circle if no arg given (sweep 0 to 360 degrees) */ static create(data?: AngleSweep | Angle): AngleSweep; /** * (private) constructor with start and end angles in radians. * * Use explicitly named static methods to clarify intent and units of inputs: * * * createStartEndRadians (startRadians:number, endRadians:number) * * createStartEndDegrees (startDegrees:number, endDegrees:number) * * createStartEnd (startAngle:Angle, endAngle:Angle) * * createStartSweepRadians (startRadians:number, sweepRadians:number) * * createStartSweepDegrees (startDegrees:number, sweepDegrees:number) * * createStartSweep (startAngle:Angle, sweepAngle:Angle) */ private constructor(); /** * Directly set the start and end angles in radians * * If the difference between startRadians and endRadians is greater than 360, the function limits the angle sweep to 360. */ setStartEndRadians(startRadians?: number, endRadians?: number): void; /** Directly set the start and end angles in degrees */ setStartEndDegrees(startDegrees?: number, endDegrees?: number): void; /** * Create an AngleSweep from start and end angles given in radians. * * If the difference between startRadians and endRadians is greater than 360, the function limits the angle sweep to 360. */ static createStartEndRadians(startRadians?: number, endRadians?: number, result?: AngleSweep): AngleSweep; /** Return the AngleSweep obtained by adding `radians` to the start and end angles of this sweep. */ clonePlusRadians(radians: number): AngleSweep; /** Return the AngleSweep obtained by subtracting `radians` from the start and end angles of this sweep. */ cloneMinusRadians(radians: number): AngleSweep; /** Create an AngleSweep from start and end angles given in degrees. */ static createStartEndDegrees(startDegrees?: number, endDegrees?: number, result?: AngleSweep): AngleSweep; /** Create an angle sweep from strongly typed start and end angles */ static createStartEnd(startAngle: Angle, endAngle: Angle, result?: AngleSweep): AngleSweep; /** Create an AngleSweep from start and end angles given in radians. */ static createStartSweepRadians(startRadians?: number, sweepRadians?: number, result?: AngleSweep): AngleSweep; /** Create an AngleSweep from start and sweep given in degrees. */ static createStartSweepDegrees(startDegrees?: number, sweepDegrees?: number, result?: AngleSweep): AngleSweep; /** Create an angle sweep with limits given as (strongly typed) angles for start and sweep */ static createStartSweep(startAngle: Angle, sweepAngle: Angle, result?: AngleSweep): AngleSweep; /** Return a sweep with limits interpolated between this and other. */ interpolate(fraction: number, other: AngleSweep): AngleSweep; /** Copy from other AngleSweep. */ setFrom(other: AngleSweep): void; /** * Create a full circle sweep (CCW). * @param startRadians start angle in radians. Defaults to 0. * @param result optional preallocated object to populate and return. */ static create360(startRadians?: number, result?: AngleSweep): AngleSweep; /** Create a sweep from the south pole to the north pole (-90 to +90). */ static createFullLatitude(): AngleSweep; /** Reverse the start and end angle in place. */ reverseInPlace(): void; /** * Return a sweep for the "other" part of the circle. * @param reverseDirection true to move backwards (CW) from start to end, false to more forwards (CCW) from start to end. */ cloneComplement(reverseDirection?: boolean, result?: AngleSweep): AngleSweep; /** Restrict start and end angles to the degree range [-90,+90]. */ capLatitudeInPlace(): void; /** * Restrict [[sweepDegrees]] to the range [-360, 360]. * The start angle and sign of the sweep angle are unchanged. */ clampToFullCircle(result?: AngleSweep): AngleSweep; /** Ask if the sweep is counterclockwise, i.e. positive sweep. */ get isCCW(): boolean; /** Ask if the sweep is a full circle. */ get isFullCircle(): boolean; /** Ask if the sweep is a full sweep from south pole to north pole. */ get isFullLatitudeSweep(): boolean; /** Return a clone of this sweep. */ clone(): AngleSweep; /** Convert fractional position in the sweep to radians. */ fractionToRadians(fraction: number): number; /** Convert fractional position in the sweep to strongly typed Angle object. */ fractionToAngle(fraction: number): Angle; /** * Return 2PI divided by the sweep radians. * * This is the number of fractional intervals required to cover a whole circle. * @returns period of the sweep, or 1 if sweep is empty. */ fractionPeriod(): number; /** * Return the fractionalized position of the given angle (as Angle) computed without consideration of * 2PI period and without consideration of angle sweep direction (CW or CCW). * * the start angle is at fraction 0 * * the end angle is at fraction 1 * * interior angles are between 0 and 1 * * negative fraction for angles "before" the start angle if start < end * * fraction larger than one for angles "after" the end angle if start < end * * fraction larger than one for angles "before" the start angle if start > end * * negative fraction for angles "after" the end angle if start > end * * does not allow period shift * @returns unbounded fraction, or 1 if sweep is empty. */ angleToUnboundedFraction(theta: Angle): number; /** * Convert a sweep fraction to the equivalent period-shifted fraction inside the sweep, or within one period of zero * on the desired side. * @param fraction fraction of the sweep. * @param radians0 start angle of sweep (in radians). * @param radians1 end angle of sweep (in radians). * @param toNegativeFraction exterior fraction handling: * * if true, return `fraction` period-shifted to within one period of the start * * if false, return `fraction` period-shifted to within one period of the end * * if undefined, return the period-shift of `fraction` closest in fraction space to [0,1]. * @returns period-shifted fraction. If `fraction` is already in [0,1], or the sweep is empty, then `fraction` is * returned unchanged. */ static fractionToSignedPeriodicFractionStartEnd(fraction: number, radians0: number, radians1: number, toNegativeFraction?: boolean): number; /** * Convert a sweep fraction to the equivalent period-shifted fraction inside this sweep, or within one period of * zero on the desired side. * @param fraction fraction of the sweep. * @param toNegativeFraction exterior fraction handling: * * if true, return `fraction` period-shifted to within one period of the start * * if false, return `fraction` period-shifted to within one period of the end * * if undefined, return the period-shift of `fraction` closest in fraction space to [0,1]. * @returns period-shifted fraction. If `fraction` is already in [0,1], or the sweep is empty, then `fraction` is * returned unchanged. */ fractionToSignedPeriodicFraction(fraction: number, toNegativeFraction?: boolean): number; /** * Return the fractionalized position of the given angle (as radians), computed with consideration of 2PI period. * * consider radians0 as `start` angle of the sweep and radians1 as `end` angle of the sweep * * the start angle is at fraction 0 * * the end angle is at fraction 1 * * interior angles are between 0 and 1 * * all exterior angles are at fractions greater than 1 * * allows period shift * @param radians input angle (in radians) * @param radians0 start angle of sweep (in radians) * @param radians1 end angle of sweep (in radians) * @param zeroSweepDefault return value when the sweep is empty (default 0) * @returns nonnegative fraction, or `zeroSweepDefault` if the sweep is empty. */ static radiansToPositivePeriodicFractionStartEnd(radians: number, radians0: number, radians1: number, zeroSweepDefault?: number): number; /** * Return the fractionalized position of the given angle (as radians), computed with consideration of 2PI period. * * the start angle is at fraction 0 * * the end angle is at fraction 1 * * interior angles are between 0 and 1 * * all exterior angles are at fractions greater than 1 * * allows period shift * @param radians input angle (in radians) * @param zeroSweepDefault return value when this sweep is empty (default 0) * @returns nonnegative fraction, or `zeroSweepDefault` if the sweep is empty. */ radiansToPositivePeriodicFraction(radians: number, zeroSweepDefault?: number): number; /** * Return the fractionalized position of the given angle (as Angle), computed with consideration of 2PI period. * * the start angle is at fraction 0 * * the end angle is at fraction 1 * * interior angles are between 0 and 1 * * all exterior angles are at fractions greater than 1 * * allows period shift * @param theta input angle * @param zeroSweepDefault return value when this sweep is empty (default 0) * @returns nonnegative fraction, or `zeroSweepDefault` if the sweep is empty. */ angleToPositivePeriodicFraction(theta: Angle, zeroSweepDefault?: number): number; /** * Return the fractionalized position of the given array of angles (as radian), computed with consideration of 2PI period. * * fraction is always positive * * the start angle is at fraction 0 * * the end angle is at fraction 1 * * interior angles are between 0 and 1 * * all exterior angles are at fractions greater than 1 * * allows period shift */ radiansArrayToPositivePeriodicFractions(data: GrowableFloat64Array): void; /** * Return the fractionalized position of the given angle (as radians) computed with consideration of * 2PI period and with consideration of angle sweep direction (CW or CCW). * * the start angle is at fraction 0 * * the end angle is at fraction 1 * * interior angles are between 0 and 1 * * negative fraction for angles "before" the start angle * * fraction larger than one for angles "after" the end angle * * allows period shift * @param radians input angle (in radians) * @param radians0 start angle of sweep (in radians) * @param radians1 end angle of sweep (in radians) * @param zeroSweepDefault return value when the sweep is empty (default 0) * @param selector how to handle an angle outside of the sweep. Default value is * [[ExteriorFractionSelector.SameSign]], to request a fraction with the same sign * as the unbounded fraction `(radians - radians0) / (radians1 - radians0)`. * @returns fraction, or `zeroSweepDefault` if the sweep is empty. */ static radiansToSignedPeriodicFractionStartEnd(radians: number, radians0: number, radians1: number, zeroSweepDefault?: number, selector?: ExteriorFractionSelector): number; /** * Return the fractionalized position of the given angle (as radians) computed with consideration of * 2PI period and with consideration of angle sweep direction (CW or CCW). * * the start angle is at fraction 0 * * the end angle is at fraction 1 * * interior angles are between 0 and 1 * * negative fraction for angles "before" the start angle * * fraction larger than one for angles "after" the end angle * * allows period shift * @param radians input angle (in radians) * @param zeroSweepDefault return value when this sweep is empty (default 0) * @param selector how to handle an angle outside of the sweep. Default value is * [[ExteriorFractionSelector.SameSign]], to request a fraction with the same sign * as the unbounded fraction `(radians - startRadians) / sweepRadians`. * @returns fraction, or `zeroSweepDefault` if this sweep is empty. */ radiansToSignedPeriodicFraction(radians: number, zeroSweepDefault?: number, selector?: ExteriorFractionSelector): number; /** * Return the fractionalized position of the given angle (as Angle) computed with consideration of * 2PI period and with consideration of angle sweep direction (CW or CCW). * * the start angle is at fraction 0 * * the end angle is at fraction 1 * * interior angles are between 0 and 1 * * negative fraction for angles "before" the start angle * * fraction larger than one for angles "after" the end angle * * allows period shift * @param theta input angle * @param zeroSweepDefault return value when this sweep is empty (default 0) * @param selector how to handle an angle outside of the sweep. Default value is * [[ExteriorFractionSelector.SameSign]], to request a fraction with the same sign * as the fraction returned by `angleToUnboundedFraction(theta)`. * @returns fraction, or `zeroSweepDefault` if this sweep is empty. */ angleToSignedPeriodicFraction(theta: Angle, zeroSweepDefault?: number, selector?: ExteriorFractionSelector): number; /** * Return the fractionalized position of the given radian angle with respect to the sweep. * * The start angle returns fraction 0 * * The end angle returns fraction 1 * * Interior angles (and their multiples of 2PI) return fractions in [0,1]. * * Exterior angles return fractions outside [0,1] according to `toNegativeFraction`. * @param radians input angle (in radians) * @param radians0 start angle of sweep (in radians) * @param radians1 end angle of sweep (in radians) * @param toNegativeFraction convert an exterior angle to a negative number (true), or to * a number greater than one (false, default). If false, this is just [[radiansToPositivePeriodicFractionStartEnd]]. * @param zeroSweepDefault return value when the sweep is empty (default 0). * @returns fraction, or `zeroSweepDefault` if the sweep is empty */ static radiansToSignedFractionStartEnd(radians: number, radians0: number, radians1: number, toNegativeFraction?: boolean, zeroSweepDefault?: number): number; /** * Return the fractionalized position of the given radian angle with respect to this sweep. * * The start angle returns fraction 0 * * The end angle returns fraction 1 * * Interior angles (and their multiples of 2PI) return fractions in [0,1]. * * Exterior angles return fractions outside [0,1] according to `toNegativeFraction`. * @param radians input angle (in radians) * @param toNegativeFraction convert an exterior angle to a negative number (true), or to * a number greater than one (false, default). If false, this is just [[radiansToPositivePeriodicFraction]]. * @param zeroSweepDefault return value when this sweep is empty (default 0). * @returns fraction, or `zeroSweepDefault` if this sweep is empty */ radiansToSignedFraction(radians: number, toNegativeFraction?: boolean, zeroSweepDefault?: number): number; /** * Return the fractionalized position of the given angle with respect to this sweep. * * The start angle returns fraction 0 * * The end angle returns fraction 1 * * Interior angles (and their multiples of 2PI) return fractions in [0,1]. * * Exterior angles return fractions outside [0,1] according to `toNegativeFraction`. * @param theta input angle * @param toNegativeFraction convert an exterior angle to a negative number (true), or to * a number greater than one (false, default). If false, this is just [[angleToPositivePeriodicFraction]]. * @param zeroSweepDefault return value when this sweep is empty (default 0). * @returns fraction, or `zeroSweepDefault` if this sweep is empty */ angleToSignedFraction(theta: Angle, toNegativeFraction?: boolean, zeroSweepDefault?: number): number; /** Test if the given angle (as radians) is within sweep (between radians0 and radians1) */ static isRadiansInStartEnd(radians: number, radians0: number, radians1: number, allowPeriodShift?: boolean): boolean; /** Test if the given angle (as radians) is within sweep */ isRadiansInSweep(radians: number, allowPeriodShift?: boolean): boolean; /** Test if the given angle (as Angle) is within the sweep */ isAngleInSweep(angle: Angle): boolean; /** * Set this AngleSweep from various sources: * * if json is undefined, a full-circle sweep is returned. * * If json is an AngleSweep object, it is cloned * * If json is an array of 2 numbers, those numbers are start and end angles in degrees. * * If `json.degrees` is an array of 2 numbers, those numbers are start and end angles in degrees. * * If `json.radians` is an array of 2 numbers, those numbers are start and end angles in radians. * * Otherwise, a full-circle sweep is returned. */ setFromJSON(json?: any): void; /** Create an AngleSweep from a json object. */ static fromJSON(json?: AngleSweepProps): AngleSweep; /** * Convert an AngleSweep to a JSON object. * @return {*} [startAngleInDegrees, endAngleInDegrees] */ toJSON(): any; /** * Test if two angle sweeps match within the given tolerance. * * Period shifts are allowed, but orientations must be the same. * @param other sweep to compare to this instance * @param radianTol optional radian tolerance, default value `Geometry.smallAngleRadians` */ isAlmostEqualAllowPeriodShift(other: AngleSweep, radianTol?: number): boolean; /** * Test if two angle sweeps match within the given tolerance. * * Period shifts are not allowed. * @param other sweep to compare to this instance * @param radianTol optional radian tolerance, default value `Geometry.smallAngleRadians` */ isAlmostEqualNoPeriodShift(other: AngleSweep, radianTol?: number): boolean; /** * Test if start and end angles match with radians tolerance. * * Period shifts are not allowed. * * This function is equivalent to isAlmostEqualNoPeriodShift. It is present for consistency with other classes. * However, it is recommended to use isAlmostEqualNoPeriodShift which has a clearer name. */ isAlmostEqual(other: AngleSweep): boolean; } //# sourceMappingURL=AngleSweep.d.ts.map