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

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: 20 June, 2023