Angle Class
An Angle
carries the numeric value of an angle, with methods to allow (require!) callers to
be clear about whether their angle is degrees or radians.
- After the Angle object is created, the callers should not know or care whether it is stored in
degrees
orradians
because both are available if requested by caller. - The various access method are named so that callers can specify whether untyped numbers passed in or out are degrees or radians.
- Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/AngleSweep
Implements
Methods
Name | Description | |
---|---|---|
addMultipleOf2PiInPlace(multiple: number): void | Add a multiple of a full circle angle (360 degrees, 2PI) in place. | |
clone(): Angle | Return a new angle with the same content. | |
cloneScaled(scale: number): Angle | Return a (new) Angle object, with angle scaled from existing angle. | |
cos(): number | Return the cosine of this Angle object's angle | |
freeze(): Readonly<Angle> | Freeze this instance so it is read-only | |
isAlmostEqual(other: Angle, radianTol: numberGeometry.smallAngleRadians): boolean | Test if this angle and other are almost equal, NOT allowing shift by full circle (i.e., multiples of 2 * PI ). |
|
isAlmostEqualAllowPeriodShift(other: Angle, radianTol: numberGeometry.smallAngleRadians): boolean | Test if this angle and other are equivalent, allowing shift by full circle (i.e., multiples of 2 * PI ). |
|
isAlmostEqualNoPeriodShift(other: Angle, radianTol: numberGeometry.smallAngleRadians): boolean | Test if this angle and other are almost equal, NOT allowing shift by full circle (i.e., multiples of 2 * PI ). |
|
isMagnitudeLessThanOrEqual(other: Angle): boolean | Test if this angle has magnitude no greater than that of other . |
|
setDegrees(degrees: number): void | Set this angle to a value given in degrees. | |
setFrom(other: Angle): void | Copy all contents of other to this Angle. |
|
setFromJSON(json?: AngleProps, defaultValRadians?: number): void | Set an Angle from a JSON object | |
setRadians(radians: number): void | Set this angle to a value given in radians. | |
sin(): number | Return the sine of this Angle object's angle | |
tan(): number | Return the tangent of this Angle object's angle | |
toJSON(): AngleProps | Convert an Angle to a JSON object as a number in degrees | |
toJSONRadians(): AngleProps | Return a json object with radians keyword, e.g. | |
adjustDegrees0To360(degrees: number): number Static | Adjust a degrees value so it is in [0, 360]. | |
adjustDegreesSigned180(degrees: number): number Static | Adjust a degrees value so it is in [-180, 180]. | |
adjustRadians0To2Pi(radians: number): number Static | Adjust a radians value so it is in [0, 2pi]. | |
adjustRadians0ToLessThan2Pi(radians: number): number Static | Adjust a radians value so it is in [0, 2pi). | |
adjustRadiansMinusPiPlusPi(radians: number): number Static | Adjust a radians value so it is in [-pi, pi] | |
cleanupTrigValue(value: number, tolerance: numberGeometry.smallFloatingPoint): number Static | If value is close to -1, -0.5, 0, 0.5, 1, adjust it to the exact value. | |
create360(): Angle Static | Create an angle for a full circle. | |
createAtan2(numerator: number, denominator: number): Angle Static | Create a (strongly typed) Angle whose tangent is numerator/denominator , using the signs of both in |
|
createDegrees(degrees: number): Angle Static | Return a new Angle object for angle given in degrees. | |
createDegreesAdjustPositive(degrees: number): Angle Static | Create an angle object with degrees adjusted into 0..360. | |
createDegreesAdjustSigned180(degrees: number): Angle Static | Create an angle object with degrees adjusted into -180..180. | |
createInterpolate(angle0: Angle, fraction: number, angle1: Angle): Angle Static | Return a (new) Angle object that is interpolated between two inputs (based on a fraction) | |
createRadians(radians: number): Angle Static | Return a (new) Angle object for a value given in radians. | |
createSmallAngle(): Angle Static | Return a new Angle object with the default "small" angle measurement specified by smallAngleRadians. |
|
degreesToRadians(degrees: number): number Static | Convert an angle in degrees to radians. | |
dotProductsToHalfAngleTrigValues(dotUU: number, dotVV: number, dotUV: number, favorZero: booleantrue): TrigValues Static | Return the half angle cosine, sine, and radians for the given vector dot products. | |
fromJSON(json?: AngleProps, defaultValRadians?: number): Angle Static | Create an Angle from a JSON object | |
isAlmostEqualRadiansAllowPeriodShift(radiansA: number, radiansB: number, radianTol: numberGeometry.smallAngleRadians): boolean Static | Test if two radian values are equivalent, allowing shift by full circle (i.e. | |
isAlmostEqualRadiansNoPeriodShift(radiansA: number, radiansB: number, radianTol: numberGeometry.smallAngleRadians): boolean Static | Test if two angles (in radians) are almost equal, NOT allowing shift by full circle (i.e., multiples of 2 * PI ). |
|
isFullCircleRadians(radians: number): boolean Static | Test if a radians (absolute) value is nearly 2PI or larger. | |
isHalfCircleRadians(radians: number): boolean Static | Test if the radians value is a half circle | |
isPerpendicularDotSet(dotUU: number, dotVV: number, dotUV: number): boolean Static | Test if dot product values indicate non-zero length perpendicular vectors. | |
orientedRadiansBetweenVectorsXYZ(ux: number, uy: number, uz: number, vx: number, vy: number, vz: number, upVectorX: number, upVectorY: number, upVectorZ: number, adjustToPositive: booleanfalse): number Static | Returns the angle between two vectors, with the vectors given as xyz components, and an up vector to resolve | |
radiansBetweenVectorsXYZ(ux: number, uy: number, uz: number, vx: number, vy: number, vz: number): number Static | Returns the angle between two vectors, with the vectors given as xyz components | |
radiansToDegrees(radians: number): number Static | Convert an angle in radians to degrees. | |
trigValuesToHalfAngleTrigValues(rCos2A: number, rSin2A: number): TrigValues Static | Compute the angle A given rcos(2A) and rsin(2A) for some nonnegative scalar r. | |
zero(): Angle Static | Return a (newly allocated) Angle object with value 0 radians |
Properties
Defined in
- geometry3d/Angle.ts Line 21
Last Updated: 21 November, 2024
Found something wrong, missing, or unclear on this page?Raise an issue in our repo.