AngleSweep Class

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 f is between 0 and 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.
  • If "start < end" the angle proceeds CCW around the unit circle.
  • If "end < start" the angle proceeds CW around the unit circle.
  • Angles beyond 360 are fine as endpoints.
  • (350,370) covers the same unit angles as (-10,10).
  • (370,350) covers the same unit angles as (10,-10).
  • math details related fraction API can be found at docs/learning/geometry/Angle.md
  • Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/AngleSweep

Implements

Methods

Name Description
angleToPositivePeriodicFraction(theta: Angle): number Return the fractionalized position of the given angle (as Angle), computed with consideration of 2PI period.  
angleToSignedPeriodicFraction(theta: Angle): number Return the fractionalized position of the given angle (as Angle) computed with consideration of  
angleToUnboundedFraction(theta: Angle): number Return the fractionalized position of the given angle (as Angle) computed without consideration of  
capLatitudeInPlace(): void Restrict start and end angles into the range (-90,+90) in degrees  
clone(): AngleSweep Return a clone of this sweep.  
cloneComplement(reverseDirection: boolean = false, result?: AngleSweep): AngleSweep Return a sweep for the "other" part of the circle.  
cloneMinusRadians(radians: number): AngleSweep Return the angle obtained by subtracting radians from this angle.  
fractionPeriod(): number Return 2PI divided by the sweep radians (i.e.  
fractionToAngle(fraction: number): Angle Convert fractional position in the sweep to strongly typed Angle object.  
fractionToRadians(fraction: number): number Convert fractional position in the sweep to radians.  
interpolate(fraction: number, other: AngleSweep): AngleSweep Return a sweep with limits interpolated between this and other.  
isAlmostEqual(other: AngleSweep): boolean Test if start and end angles match with radians tolerance.  
isAlmostEqualAllowPeriodShift(other: AngleSweep): boolean Test if this angle sweep and other angle sweep match with radians tolerance.  
isAlmostEqualNoPeriodShift(other: AngleSweep): boolean Test if this angle sweep and other angle sweep match with radians tolerance.  
isAngleInSweep(angle: Angle): boolean Test if the given angle (as Angle) is within the sweep  
isRadiansInSweep(radians: number, allowPeriodShift: boolean = true): boolean Test if the given angle (as radians) is within sweep  
radiansArrayToPositivePeriodicFractions(data: GrowableFloat64Array): void Return the fractionalized position of the given array of angles (as radian), computed with consideration of 2PI period.  
radiansToPositivePeriodicFraction(radians: number, zeroSweepDefault: number = 0.0): number Return the fractionalized position of the given angle (as radians), computed with consideration of 2PI period.  
radiansToSignedPeriodicFraction(radians: number): number Return the fractionalized position of the given angle (as radian) computed with consideration of  
reverseInPlace(): void Reverse the start and end angle in place.  
setFrom(other: AngleSweep): void Copy from other AngleSweep.  
setFromJSON(json?: any): void Set this AngleSweep from various sources:  
setStartEndDegrees(startDegrees: number = 0, endDegrees: number = 360.0): void Directly set the start and end angles in degrees  
setStartEndRadians(startRadians: number = 0, endRadians: number = ...): void Directly set the start and end angles in radians  
toJSON(): any Convert an AngleSweep to a JSON object.  
create(data?: Angle | AngleSweep): AngleSweep Static Create a sweep as one of  
create360(startRadians?: number): AngleSweep Static Create a full circle sweep (CCW).  
createFullLatitude(): AngleSweep Static Create a sweep from the south pole to the north pole (-90 to +90).  
createStartEnd(startAngle: Angle, endAngle: Angle, result?: AngleSweep): AngleSweep Static Create an angle sweep from strongly typed start and end angles  
createStartEndDegrees(startDegrees: number = 0, endDegrees: number = 360, result?: AngleSweep): AngleSweep Static Create an AngleSweep from start and end angles given in degrees.  
createStartEndRadians(startRadians: number = 0, endRadians: number = ..., result?: AngleSweep): AngleSweep Static Create an AngleSweep from start and end angles given in radians.  
createStartSweep(startAngle: Angle, sweepAngle: Angle, result?: AngleSweep): AngleSweep Static Create an angle sweep with limits given as (strongly typed) angles for start and sweep  
createStartSweepDegrees(startDegrees: number = 0, sweepDegrees: number = 360, result?: AngleSweep): AngleSweep Static Create an AngleSweep from start and sweep given in degrees.  
createStartSweepRadians(startRadians: number = 0, sweepRadians: number = Math.PI, result?: AngleSweep): AngleSweep Static Create an AngleSweep from start and end angles given in radians.  
fromJSON(json?: AngleSweepProps): AngleSweep Static Create an AngleSweep from a json object.  
isRadiansInStartEnd(radians: number, radians0: number, radians1: number, allowPeriodShift: boolean = true): boolean Static Test if the given angle (as radians) is within sweep (between radians0 and radians1)  
radiansToPositivePeriodicFractionStartEnd(radians: number, radians0: number, radians1: number, zeroSweepDefault: number = 0.0): number Static Return the fractionalized position of the given angle (as radians), computed with consideration of 2PI period.  

Properties

Name Type Description
endAngle Accessor ReadOnly Angle Return the (strongly typed) end angle  
endDegrees Accessor ReadOnly number Read-property for degrees at the end of this AngleSweep.  
endRadians Accessor ReadOnly number Read-property for degrees at the end of this AngleSweep.  
isCCW Accessor ReadOnly boolean Ask if the sweep is counterclockwise, i.e.  
isFullCircle Accessor ReadOnly boolean Ask if the sweep is a full circle.  
isFullLatitudeSweep Accessor ReadOnly boolean Ask if the sweep is a full sweep from south pole to north pole.  
startAngle Accessor ReadOnly Angle Return the (strongly typed) start angle  
startDegrees Accessor ReadOnly number Read-property for degrees at the start of this AngleSweep.  
startRadians Accessor ReadOnly number Read-property for degrees at the start of this AngleSweep.  
sweepDegrees Accessor ReadOnly number Read-property for signed start-to-end sweep in degrees.  
sweepRadians Accessor ReadOnly number Read-property for signed start-to-end sweep in radians.  

Defined in

Last Updated: 29 March, 2024