Geometry Class
Class containing static methods for typical numeric operations.
- Experimentally, methods like Geometry.hypotenuse are observed to be faster than the system intrinsics.
- This is probably due to
- Fixed length arg lists
- strongly typed parameters
Methods
Name | Description | |
---|---|---|
constructor(): Geometry | ||
almostEqualArrays<T>(a: T[], b: T[], testFunction: (p: T, q: T) => boolean): boolean Static | Test for match of two arrays of type T . |
|
almostEqualNumberArrays(a: Float64Array | number[], b: Float64Array | number[], testFunction: (p: number, q: number) => boolean): boolean Static | Test for match of two arrays of type number or Float64Array. | |
areEqualAllowUndefined<T>(a: T, b: T, resultIfBothUndefined: booleantrue): boolean Static | Test for match of two values of type T . |
|
axisIndexToRightHandedAxisOrder(axisIndex: AxisIndex): AxisOrder Static | Return the AxisOrder for which axisIndex is the first named axis. |
|
axisOrderToAxis(order: AxisOrder, index: number): number Static | Given an axisOrder (e.g. |
|
clamp(value: number, min: number, max: number): number Static | Clamp value to (min, max) with no test for order of (min, max). | |
clampToStartEnd(value: number, a: number, b: number): number Static | Clamp to (min(a,b), max(a,b)). | |
cloneArray<T extends ICloneable<T>>(array: T[]): undefined | T[] Static | Clone an array whose members have the cloneable type T . |
|
cloneMembers<T extends Cloneable<T>>(array: T[]): undefined | T[] Static | Clone an array whose members have type T , which implements the clone method. |
|
conditionalDivideCoordinate(numerator: number, denominator: number, largestResult: numberGeometry.largeCoordinateResult): undefined | number Static | Return numerator divided by denominator (with a given largestResult ). |
|
conditionalDivideFraction(numerator: number, denominator: number): undefined | number Static | Return numerator divided by denominator . |
|
correctSmallFraction(fraction: number, replacement: number0.0): number Static | Correct a small fraction. | |
correctSmallMetricDistance(distance: number, replacement: number0.0): number Static | Correct a small distance. | |
crossProductMagnitude(ux: number, uy: number, uz: number, vx: number, vy: number, vz: number): number Static | Magnitude of 3D cross product of vectors with the vectors presented as numbers. | |
crossProductXYXY(ux: number, uy: number, vx: number, vy: number): number Static | 2D cross product of vectors with the vectors presented as numbers. | |
crossProductXYZXYZ(ux: number, uy: number, uz: number, vx: number, vy: number, vz: number, result?: Vector3d): Vector3d Static | 3D cross product of vectors with the vectors presented as numbers. | |
curvatureMagnitude(ux: number, uy: number, uz: number, vx: number, vy: number, vz: number): number Static | Returns curvature from the first and second derivative vectors. | |
cyclic3dAxis(axis: number): number Static | Return axis modulo 3 with proper handling of negative indices |
|
defined01(value: any): number Static | Return 0 if the value is undefined and 1 if the value is defined. |
|
determinant4x4(xx: number, xy: number, xz: number, xw: number, yx: number, yy: number, yz: number, yw: number, zx: number, zy: number, zz: number, zw: number, wx: number, wy: number, wz: number, ww: number): number Static | Returns the determinant of the 4x4 matrix unrolled as the 16 parameters | |
distanceXYXY(x0: number, y0: number, x1: number, y1: number): number Static | Return the distance between xy points given as numbers. | |
distanceXYZXYZ(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number): number Static | Return the distance between xyz points given as numbers. | |
dotProductXYXY(ux: number, uy: number, vx: number, vy: number): number Static | 2D dot product of vectors with the vectors presented as numbers. | |
dotProductXYZXYZ(ux: number, uy: number, uz: number, vx: number, vy: number, vz: number): number Static | 3D dot product of vectors with the vectors presented as numbers. | |
equalStringNoCase(string1: string, string2: string): boolean Static | Case-insensitive string comparison. | |
exactEqualNumberArrays(a: number[], b: number[]): boolean Static | Test for exact match of two number arrays. | |
hypotenuseSquaredXY(x: number, y: number): number Static | Return the squared hypotenuse (i.e., x*x + y*y ). |
|
hypotenuseSquaredXYZ(x: number, y: number, z: number): number Static | Return the squared hypotenuse (i.e., x*x + y*y + z*z ). |
|
hypotenuseSquaredXYZW(x: number, y: number, z: number, w: number): number Static | Return the squared hypotenuse (i.e., x*x + y*y + z*z + w*w ). |
|
hypotenuseXY(x: number, y: number): number Static | Return the hypotenuse (i.e., sqrt(x*x + y*y) ). |
|
hypotenuseXYZ(x: number, y: number, z: number): number Static | Return the hypotenuse (i.e., sqrt(x*x + y*y + z*z) ). |
|
hypotenuseXYZW(x: number, y: number, z: number, w: number): number Static | Return the full 4d hypotenuse (i.e., sqrt(x*x + y*y + z*z + w*w) ). |
|
interpolate(a: number, f: number, b: number): number Static | Simple interpolation between values a and b with fraction f . |
|
interpolateColor(color0: number, fraction: number, color1: number): number Static | Interpolate each byte of color0 and color1 as integers. | |
inverseInterpolate(x0: number, f0: number, x1: number, f1: number, fTarget: number0, defaultResult?: number): undefined | number Static | For a line f(x) where f(x0) = f0 and f(x1) = f1 , return the x value at which f(x) = fTarget . |
|
inverseInterpolate01(f0: number, f1: number, fTarget: number0): undefined | number Static | For a line f(x) where f(0) = f0 and f(1) = f1 , return the x value at which f(x) = fTarget |
|
inverseMetricDistance(distance: number): undefined | number Static | Compute the inverse of distance , checking for safe division. |
|
inverseMetricDistanceSquared(distanceSquared: number): undefined | number Static | Return the inverse of distanceSquared , checking for safe division. |
|
isAlmostEqualEitherNumber(a: number, b: number, c: number, tolerance: numberGeometry.smallAngleRadians): boolean Static | Toleranced test for equality to at least one of two numbers. | |
isAlmostEqualNumber(a: number, b: number, tolerance: numberGeometry.smallAngleRadians): boolean Static | Toleranced equality test. | |
isAlmostEqualOptional(a: number, b: number, tolerance: number): boolean Static | Returns true if both values are undefined or if both are defined and almost equal within tolerance. |
|
isAlmostEqualXAndY(a: Readonly<WritableXAndY>, b: Readonly<WritableXAndY>, tolerance: numberGeometry.smallAngleRadians): boolean Static | Toleranced equality test using tolerance tolerance * ( 1 + abs(a.x) + abs(a.y) + abs(b.x) + abs(b.y) ) . |
|
isArrayOfNumberArray(json: any, minArrays: number, minEntries: number0): json is number[][] Static | Return true if json is an array of at least minArrays arrays with at least minEntries entries in |
|
isDistanceWithinTol(distance: number, tolerance: numberGeometry.smallMetricDistance): boolean Static | Toleranced equality test using caller-supplied tolerance . |
|
isHugeCoordinate(x: number): boolean Static | Test if the absolute value of x is at least largeCoordinateResult. | Deprecated |
isIn01(x: number, apply01: booleantrue): boolean Static | Test if x is in the interval [0,1] (but skip the test if apply01 = false ). |
|
isIn01WithTolerance(x: number, tolerance: number): boolean Static | Test if x is in the interval [0,1] for a given tolerance . |
|
isLargeCoordinateResult(x: number): boolean Static | Test if the absolute value of x is at least largeCoordinateResult. | |
isNumberArray(json: any, minEntries: number0): json is number[] Static | Return true if json is an array with at least minEntries entries and all entries are numbers (including |
|
isOdd(x: number): boolean Static | Test if a number is odd | |
isSameCoordinate(x: number, y: number, tolerance: numberGeometry.smallMetricDistance): boolean Static | Boolean test for metric coordinate near-equality (i.e., if x and y are almost equal) using tolerance . |
|
isSameCoordinateSquared(x: number, y: number, tolerance: numberGeometry.smallMetricDistance): boolean Static | Boolean test for squared metric coordinate near-equality (i.e., if sqrt(x) and sqrt(y) are |
|
isSameCoordinateWithToleranceFactor(x: number, y: number, toleranceFactor: number): boolean Static | Boolean test for metric coordinate near-equality (i.e., if x and y are almost equal) using |
|
isSameCoordinateXY(x0: number, y0: number, x1: number, y1: number, tolerance: numberGeometry.smallMetricDistance): boolean Static | Boolean test for metric coordinate pair near-equality (i.e., if x0 and x1 are almost equal |
|
isSamePoint2d(dataA: Point2d, dataB: Point2d, tolerance: numberGeometry.smallMetricDistance): boolean Static | Boolean test for small xy-distance within tolerance . |
|
isSamePoint3d(dataA: Point3d, dataB: Point3d, tolerance: numberGeometry.smallMetricDistance): boolean Static | Boolean test for small dataA.distance(dataB) within tolerance . |
|
isSamePoint3dXY(dataA: Point3d, dataB: Point3d, tolerance: numberGeometry.smallMetricDistance): boolean Static | Boolean test for small xy-distance (ignoring z) within tolerance . |
|
isSameVector2d(dataA: Vector2d, dataB: Vector2d, tolerance: numberGeometry.smallMetricDistance): boolean Static | Boolean test for small xy-distance within tolerance . |
|
isSameVector3d(dataA: Vector3d, dataB: Vector3d, tolerance: numberGeometry.smallMetricDistance): boolean Static | Boolean test for small xyz-distance within tolerance . |
|
isSameXYZ(dataA: XYZ, dataB: XYZ, tolerance: numberGeometry.smallMetricDistance): boolean Static | Boolean test for small xyz-distance within tolerance . |
|
isSmallAngleRadians(value: number): boolean Static | Test if value is at most smallAngleRadians in absolute value. |
|
isSmallAngleRadiansSquared(value: number): boolean Static | Test if value is at most smallAngleRadiansSquared in absolute value. |
|
isSmallMetricDistance(distance: number): boolean Static | Toleranced equality test using smallMetricDistance tolerance. | |
isSmallMetricDistanceSquared(distanceSquared: number): boolean Static | Toleranced equality test using smallMetricDistanceSquared tolerance. | |
isSmallRelative(value: number): boolean Static | Test if value is at most smallFraction in absolute value. |
|
lexicalXYLessThan(a: XY | XYZ, b: XY | XYZ): "-1" | "0" | "1" Static | Lexical comparison of (a.x, a.y) and (b.x, b.y) with x as first test and y as second (z is ignored). | |
lexicalXYZLessThan(a: XYZ, b: XYZ): "-1" | "0" | "1" Static | Lexical comparison of (a.x, a.y, a.z) and (b.x, b.y, b.z) with x as first test, y as second, and z as third. | |
lexicalYXLessThan(a: XY | XYZ, b: XY | XYZ): "-1" | "0" | "1" Static | Lexical comparison of (a.x, a.y) and (b.x, b.y) with y as first test and x as second (z is ignored). | |
maxAbsDiff(a: number, b0: number, b1: number): number Static | Return the largest absolute distance from a to either of b0 or b1 |
|
maxAbsXY(x: number, y: number): number Static | Return the largest absolute value among x and y |
|
maxAbsXYZ(x: number, y: number, z: number): number Static | Return the largest absolute value among x , y , and z |
|
maxXY(a: number, b: number): number Static | Return the largest signed value among a and b |
|
maxXYZ(a: number, b: number, c: number): number Static | Return the largest signed value among a , b , and c |
|
meanCurvatureOfRadii(r0: number, r1: number): number Static | Return the mean curvature for two radii. | |
minXY(a: number, b: number): number Static | Return the smallest signed value among a and b |
|
minXYZ(a: number, b: number, c: number): number Static | Return the smallest signed value among a , b , and c |
|
modulo(a: number, period: number): number Static | Return a modulo period . |
|
resolveNumber(value: number, defaultValue: number0): number Static | If given a value , return it. |
|
resolveToUndefined<T>(value: T, targetValue: T): undefined | T Static | If given value matches the targetValue , return undefined . |
|
resolveValue<T>(value: T, defaultValue: T): T Static | If given a value , return it. |
|
restrictToInterval(x: number, a: number, b: number): number Static | Restrict x so it is in the interval [a,b] (allowing a and b to be in either order). |
|
safeDivideFraction(numerator: number, denominator: number, defaultResult: number): number Static | Return numerator divided by denominator . |
|
solveTrigForm(constCoff: number, cosCoff: number, sinCoff: number): undefined | Vector2d[] Static | Return solution(s) of equation constCoff + cosCoff*c + sinCoff*s = 0 for c and s with the |
|
split3Way01(x: number, tolerance: numberGeometry.smallMetricDistance): "-1" | "0" | "1" Static | Examine the value (particularly sign) of x. | |
split3WaySign(x: number, outNegative: number, outZero: number, outPositive: number): number Static | Examine the sign of x . |
|
square(x: number): number Static | Return the square of x | |
stepCount(stepSize: number, total: number, minCount: number1, maxCount: number101): number Static | Return the number of steps to take so that numSteps * stepSize >= total . |
|
tripleProduct(ux: number, uy: number, uz: number, vx: number, vy: number, vz: number, wx: number, wy: number, wz: number): number Static | Returns the triple product of 3 vectors provided as x,y,z number sequences. | |
tripleProductPoint4dXYW(columnA: Point4d, columnB: Point4d, columnC: Point4d): number Static | Returns the determinant of 3x3 matrix columns created by the given Point4d ignoring the z part: |
|
tripleProductXYW(columnA: Readonly<WritableXAndY>, weightA: number, columnB: Readonly<WritableXAndY>, weightB: number, columnC: Readonly<WritableXAndY>, weightC: number): number Static | Returns the determinant of 3x3 matrix with first and second rows created from the 3 xy points and the third |
Properties
Name | Type | Description | |
---|---|---|---|
fullCircleRadiansMinusSmallAngle Static Readonly | number | Radians value for full circle 2PI radians minus smallAngleRadians. | |
hugeCoordinate Static Readonly | "1000000000000" | Numeric value that may considered infinite for metric coordinates. | Deprecated |
largeCoordinateResult Static Readonly | "10000000000000" | Numeric value that may considered large for numbers expected to be coordinates. | |
largeFractionResult Static Readonly | "10000000000" | Numeric value that may be considered large for a ratio of numbers. | |
smallAngleDegrees Static Readonly | "5.7e-11" | Tolerance for small angle measured in degrees. | |
smallAngleRadians Static Readonly | "1e-12" | Tolerance for small angle measured in radians. | |
smallAngleRadiansSquared Static Readonly | "1e-24" | Square of smallAngleRadians. | |
smallAngleSeconds Static Readonly | "2e-7" | Tolerance for small angle measured in arc-seconds. | |
smallFloatingPoint Static Readonly | "1e-15" | Tight tolerance near machine precision (unitless). | |
smallFraction Static Readonly | "1e-10" | Numeric value that may be considered zero for fractions between 0 and 1. | |
smallMetricDistance Static Readonly | "0.000001" | Tolerance for small distances in metric coordinates. | |
smallMetricDistanceSquared Static Readonly | "1e-12" | Square of smallMetricDistance. |
Defined in
- Geometry.ts Line 254
Last Updated: 21 November, 2024
Found something wrong, missing, or unclear on this page?Raise an issue in our repo.