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).

Implements

Methods

Name Description
angleToPositivePeriodicFraction(theta: Angle): number map an angle to a fractional coordinate which is:  
angleToSignedPeriodicFraction(theta: Angle): number map an angle to a fractional coordinate which is:  
angleToUnboundedFraction(theta: Angle): number return the fractionalized position of the angle,  
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 circe.  
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 start and end angles match, with explicit name to clarify that there is no test for 360-degree shifts.  
isAlmostEqualNoPeriodShift(other: AngleSweep): boolean test if start and end angles match, explicit name to clarify that 360-degree shifts are allowed.  
isAngleInSweep(angle: Angle): boolean test if an angle is within the sweep  
isRadiansInSweep(radians: number, allowPeriodShift: boolean = true): boolean test if radians are within sweep  
radiansArrayToPositivePeriodicFractions(data: GrowableFloat64Array): void Convert each value in an array from radians to fraction.  
radiansToPositivePeriodicFraction(radians: number, zeroSweepDefault: number = 0.0): number Convert a radians value to a fraction that is always positive and can wrap.  
radiansToSignedPeriodicFraction(radians: number): number Convert a radians value to a fraction, allowing wraparound.  
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.  
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 radians are within sweep  
radiansToPositivePeriodicFractionStartEnd(radians: number, radians0: number, radians1: number, zeroSweepDefault: number = 0.0): number Static Convert a radians value to a fraction that is always positive and can wrap.  

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: 12 June, 2024