XY Class
Minimal object containing x,y and operations that are meaningful without change in both point and vector.
XY
is not instantiable.- The derived (instantiable) classes are
Point2d
Vector2d
Extended by
Implements
Methods
Name | Description | |
---|---|---|
constructor(x: number = 0, y: number = 0): XY Protected | ||
at(index: number): number | Return the x,y component corresponding to 0,1. | |
distance(other: Readonly<WritableXAndY>): number | Return the distance from this point to other | |
distanceSquared(other: Readonly<WritableXAndY>): number | Return squared distance from this point to other | |
freeze(): Readonly<XY> | Freeze this instance so it is read-only | |
indexOfMaxAbs(): number | Return the index (0,1) of the x,y component with largest absolute value | |
isAlmostEqual(other: Readonly<WritableXAndY>, tol?: number): boolean | Returns true if this and other have equal x,y parts within Geometry.smallMetricDistance. | |
isAlmostEqualMetric(other: Readonly<WritableXAndY>, distanceTol: number = Geometry.smallMetricDistance): boolean | returns true if x,y match other within metric tolerance |
|
isAlmostEqualXY(x: number, y: number, tol?: number): boolean | Returns true if this and other have equal x,y parts within Geometry.smallMetricDistance. | |
isExactEqual(other: Readonly<WritableXAndY>): boolean | returns true if the x,y components are exactly equal. | |
magnitude(): number | Return the magnitude of the vector | |
magnitudeSquared(): number | Return the squared magnitude of the vector. | |
maxAbs(): number | Return the largest absolute value of any component | |
maxDiff(other: Readonly<WritableXAndY>): number | Return the largest absolute distance between corresponding components | |
set(x: number = 0, y: number = 0): void | Set both x and y. | |
setAt(index: number, value: number): void | Set value at index 0 or 1. | |
setFrom(other?: Readonly<WritableXAndY>): void | Set both x and y from other. | |
setFromJSON(json?: XYProps): void | Set x and y from a JSON input such as [1,2] or {x:1, y:2} |
|
setZero(): void | Set both x and y to zero | |
toJSON(): XYProps | return a json array [x,y] |
|
toJSONXY(): XYProps | return a json object {x: 1, y:2} |
|
unitVectorTo(other: Readonly<WritableXAndY>, result?: Vector2d): undefined | Vector2d | Return a unit vector from this point to other | |
vectorTo(other: Readonly<WritableXAndY>, result?: Vector2d): Vector2d | Return a (full length) vector from this point to other | |
crossProductToPoints(origin: Readonly<WritableXAndY>, targetA: Readonly<WritableXAndY>, targetB: Readonly<WritableXAndY>): number Static | cross product of vectors from origin to targets |
Properties
Name | Type | Description | |
---|---|---|---|
isAlmostZero Accessor ReadOnly | boolean | returns true if the x,y components are both small by metric metric tolerance | |
x | number | x component | |
y | number | y component |
Defined in
- geometry3d/Point2dVector2d.ts Line 23
Last Updated: 30 November, 2023