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: undefined | T[], b: undefined | T[], testFunction: (p: T, q: T) => boolean): boolean Static | test for match of XYZ arrays. | |
almostEqualNumberArrays(a: undefined | number[] | Float64Array, b: undefined | number[] | Float64Array, testFunction: (p: number, q: number) => boolean): boolean Static | test for match of typed arrays (e.g. | |
areEqualAllowUndefined<T>(a: undefined | T, b: undefined | T, resultIfBothUndefined: boolean = true): boolean Static | Return | |
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(x: number, a: number, b: number): number Static | Clamp to (min(a,b), max(a,b)) | |
cloneMembers<T extends Cloneable<T, T>>(a: undefined | T[]): undefined | T[] Static | clone an array whose members have a clone method. | |
conditionalDivideCoordinate(numerator: number, denominator: number, largestResult: number = Geometry.largeCoordinateResult): undefined | number Static | normally, return numerator/denominator. | |
conditionalDivideFraction(numerator: number, denominator: number): undefined | number Static | normally, return numerator/denominator. | |
correctSmallMetricDistance(distance: undefined | number, replacement: number = 0.0): number Static | Correct distance to zero if undefined or smaller than metric tolerance. |
|
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 | |
crossProductXYXY(ux: number, uy: number, vx: number, vy: number): number Static | 2D cross product of vectors layed out as scalars. | |
crossProductXYZXYZ(ux: number, uy: number, uz: number, vx: number, vy: number, vz: number, result?: Vector3d): Vector3d Static | 3D cross product of vectors layed out as scalars. | |
curvatureMagnitude(ux: number, uy: number, uz: number, vx: number, vy: number, vz: number): number Static | Returns curvature magnitude from a first and second derivative vector. | |
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, 1 if 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 layed out as scalars. | |
dotProductXYZXYZ(ux: number, uy: number, uz: number, vx: number, vy: number, vz: number): number Static | 3D dot product of vectors layed out as scalars. | |
equalStringNoCase(string1: string, string2: string): boolean Static | Case-insensitive string comparison. | |
exactEqualNumberArrays(a: undefined | number[], b: undefined | number[]): boolean Static | test for EXACT match of number arrays. | |
hypotenuseSquaredXY(x: number, y: number): number Static | Return the squared hypotenuse (x*x + y*y) . |
|
hypotenuseSquaredXYZ(x: number, y: number, z: number): number Static | Return the squared hypotenuse (x*x + y*y + z*z) . |
|
hypotenuseSquaredXYZW(x: number, y: number, z: number, w: number): number Static | Return the squared hypotenuse (x*x + y*y + z*z+w*w) . |
|
hypotenuseXY(x: number, y: number): number Static | Return the hypotenuse sqrt(x*x + y*y) . |
|
hypotenuseXYZ(x: number, y: number, z: number): number Static | Return the hypotenuse sqrt(x*x + y*y + z*z) . |
|
hypotenuseXYZW(x: number, y: number, z: number, w: number): number Static | Return the (full 4d) hypotenuse sqrt(x*x + y*y + z*z + w*w) . |
|
interpolate(a: number, f: number, b: number): number Static | Simple interpolation between values, but choosing (based on fraction) a or b as starting point for maximum accuracy. | |
inverseInterpolate(x0: number, f0: number, x1: number, f1: number, targetF: number = 0, defaultResult?: number): undefined | number Static | For a line f(x) whose function values at x0 and x1 are f0 and f1, return the x value at which f(x)=fTarget; | |
inverseInterpolate01(f0: number, f1: number, targetF: number = 0): undefined | number Static | For a line f(x) whose function values at x=0 and x=1 are f0 and f1, return the x value at which f(x)=fTarget; | |
inverseMetricDistance(a: number): undefined | number Static | If a is large enough for safe division, return 1/a , using Geometry.smallMetricDistance as the tolerance for declaring it as divide by zero. |
|
inverseMetricDistanceSquared(a: number): undefined | number Static | If a is large enough, return 1/a , using the square of Geometry.smallMetricDistance as the tolerance for declaring it as divide by zero. |
|
isAlmostEqualNumber(a: number, b: number): boolean Static | Toleranced equality test, using tolerance smallAngleRadians * ( 1 + abs(a) + (abs(b))) |
|
isAlmostEqualOptional(a: undefined | number, b: undefined | 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>): boolean Static | Toleranced equality test, using tolerance smallAngleRadians * ( 1 + abs(a) + (abs(b))) |
|
isArrayOfNumberArray(json: any, numNumberArray: number, minEntries: number = 0): boolean Static | Return true if json is an array of at least numNumberArrays, with at least minEntries in each number array. | |
isDistanceWithinTol(distance: number, tol?: number): boolean Static | Toleranced equality test, using caller-supplied tolerance. | |
isHugeCoordinate(x: number): boolean Static | Test if absolute value of x is huge. | |
isIn01(x: number, apply01: boolean = true): boolean Static | Test if x is in simple 0..1 interval. | |
isIn01WithTolerance(x: number, tolerance: number): boolean Static | Test if x is in simple 0..1 interval. | |
isNumberArray(json: any, minEntries: number = 0): boolean Static | Return true if json is an array with at least minEntries, and all entries are numbers (including those beyond minEntries) | |
isOdd(x: number): boolean Static | Test if a number is odd. | |
isSameCoordinate(x: number, y: number, tol?: number): boolean Static | Boolean test for metric coordinate near-equality | |
isSameCoordinateSquared(x: number, y: number): boolean Static | Boolean test for squared metric coordinate near-equality | |
isSameCoordinateWithToleranceFactor(x: number, y: number, toleranceFactor: number): boolean Static | Boolean test for metric coordinate near-equality, with toleranceFactor applied to the usual smallMetricDistance | |
isSameCoordinateXY(x0: number, y0: number, x1: number, y1: number, tol: number = Geometry.smallMetricDistance): boolean Static | Boolean test for metric coordinate near-equality of x, y pair | |
isSamePoint2d(dataA: Point2d, dataB: Point2d): boolean Static | boolean test for small dataA.distanceXY (dataB) within smallMetricDistance |
|
isSamePoint3d(dataA: Point3d, dataB: Point3d): boolean Static | boolean test for small dataA.distance (dataB) within smallMetricDistance |
|
isSamePoint3dXY(dataA: Point3d, dataB: Point3d): boolean Static | boolean test for small dataA.distanceXY (dataB) within smallMetricDistance |
|
isSameVector2d(dataA: Vector2d, dataB: Vector2d): boolean Static | boolean test for small dataA.distanceXY (dataB) within smallMetricDistance |
|
isSameVector3d(dataA: Vector3d, dataB: Vector3d): boolean Static | boolean test for small dataA.distanceXY (dataB) within smallMetricDistance |
|
isSameXYZ(dataA: XYZ, dataB: XYZ): boolean Static | boolean test for distance between XYZ objects within smallMetricDistance |
|
isSmallAngleRadians(value: number): boolean Static | Test if value is small compared to smallAngleRadians |
|
isSmallMetricDistance(distance: number): boolean Static | Toleranced equality test, using smallMetricDistance tolerance. |
|
isSmallMetricDistanceSquared(distanceSquared: number): boolean Static | Toleranced equality, using smallMetricDistanceSquared tolerance. |
|
isSmallRelative(value: number): boolean Static | Test if value is small compared to smallAngleRadians . |
|
lexicalXYLessThan(a: XYZ | XY, b: XYZ | XY): | "1" | "-1" Static | Lexical comparison of (a.x,a.y) (b.x,b.y) with x as first test, y second. | |
lexicalXYZLessThan(a: XYZ, b: XYZ): | "1" | "-1" Static | Lexical test, based on x first, y second, z third. | |
lexicalYXLessThan(a: XYZ | XY, b: XYZ | XY): | "1" | "-1" Static | Lexical comparison of (a.x,a.y) (b.x,b.y) with y as first test, x second. | |
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 absolute value among x,y | |
maxAbsXYZ(x: number, y: number, z: number): number Static | Return the largest absolute absolute value among x,y,z | |
maxXY(a: number, b: number): number Static | Return the largest signed value among a, b | |
maxXYZ(a: number, b: number, c: number): number Static | Return the largest signed value among a, b, c | |
meanCurvatureOfRadii(r0: number, r1: number): number Static | Return the mean curvature for two radii, with 0 radius implying 0 curvature | |
minXY(a: number, b: number): number Static | Return the smallest signed value among a, b | |
modulo(a: number, period: number): number Static | Return (a modulo period), e.g. | |
resolveNumber(value: undefined | number, defaultValue: number = 0): number Static | If given a number, return it. | |
resolveToUndefined<T>(value: undefined | T, targetValue: T): undefined | T Static | If given value matches a target, return undefined. | |
resolveValue<T>(value: undefined | 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,b to be in either order. |
|
safeDivideFraction(numerator: number, denominator: number, defaultResult: number): number Static | normally, return the number result of conditionalDivideFraction. | |
solveTrigForm(constCoff: number, cosCoff: number, sinCoff: number): undefined | Vector2d[] Static | return the 0, 1, or 2 pairs of (c,s) values that solve | |
split3WaySign(x: number, outNegative: number, outZero: number, outPositive: number): number Static | Examine the value (particularly sign) of x. | |
square(x: number): number Static | Return the square of x | |
stepCount(stepSize: number, total: number, minCount: number = 1, maxCount: number = 101): 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 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 with x and y rows taken from 3 points, third row from corresponding numbers. | |
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 x and y rows taken from 3 points, third row from corresponding numbers. |
Properties
Name | Type | Description | |
---|---|---|---|
fullCircleRadiansMinusSmallAngle StaticReadonly | number | Radians value for full circle 2PI radians minus smallAngleRadians |
|
hugeCoordinate StaticReadonly | "1000000000000" | numeric value that may considered infinite for metric coordinates. | |
largeCoordinateResult StaticReadonly | "10000000000000" | numeric value that may considered huge for numbers expected to be coordinates. | |
largeFractionResult StaticReadonly | "10000000000" | numeric value that may be considered huge for a ratio of numbers. | |
smallAngleDegrees StaticReadonly | "5.7e-11" | tolerance for small angle measured in degrees. | |
smallAngleRadians StaticReadonly | "1e-12" | tolerance for small angle measured in radians. | |
smallAngleRadiansSquared StaticReadonly | "1e-24" | square of smallAngleRadians |
|
smallAngleSeconds StaticReadonly | "2e-7" | tolerance for small angle measured in arc-seconds. | |
smallFraction StaticReadonly | "1e-10" | numeric value that may be considered zero for fractions between 0 and 1. | |
smallMetricDistance StaticReadonly | "0.000001" | Tolerance for small distances in metric coordinates | |
smallMetricDistanceSquared StaticReadonly | "1e-12" | Square of smallMetricTolerance |
Defined in
- Geometry.ts Line 207
Last Updated: 20 June, 2023