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
degreesorradiansbecause 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.
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: number = Geometry.smallAngleRadians): boolean | Test if two this angle and other are almost equal, NOT allowing shift by full circle (i.e., multiples of 2 * PI). |
|
| isAlmostEqualAllowPeriodShift(other: Angle, radianTol: number = Geometry.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: number = Geometry.smallAngleRadians): boolean | Test if two this angle and other are almost equal, NOT allowing shift by full circle (i.e., multiples of 2 * PI). |
|
| 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 radians value so it is positive in 0..360 | |
| adjustDegreesSigned180(degrees: number): number Static | Adjust a radians value so it is in -180..180 | |
| adjustRadians0To2Pi(radians: number): number Static | Adjust a radians value so it is positive in 0..2Pi | |
| adjustRadiansMinusPiPlusPi(radians: number): number Static | Adjust a radians value so it is positive in -PI..PI | |
| cleanupTrigValue(value: number, tolerance: number = 1.0e-15): 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. | |
| degreesToRadians(degrees: number): number Static | Convert an angle in degrees to radians. | |
| dotProductsToHalfAngleTrigValues(dotUU: number, dotVV: number, dotUV: number, favorZero: boolean = true): TrigValues Static | Return the half angle cosine, sine, and radians for given dot products between vectors. | |
| fromJSON(json?: AngleProps, defaultValRadians?: number): Angle Static | Create an Angle from a JSON object | |
| isAlmostEqualRadiansAllowPeriodShift(radiansA: number, radiansB: number, radianTol: number = Geometry.smallAngleRadians): boolean Static | Test if two radians values are equivalent, allowing shift by full circle (i.e. | |
| isAlmostEqualRadiansNoPeriodShift(radiansA: number, radiansB: number, radianTol: number = Geometry.smallAngleRadians): boolean Static | Test if two angle (in radians) 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. | |
| 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 | Return cosine, sine, and radians for the half angle of a "cosine,sine" pair. | |
| zero(): Angle Static | return a (newly allocated) Angle object with value 0 radians |
Properties
Defined in
- geometry3d/Angle.ts Line 20
Last Updated: 30 November, 2023