Point2d Class
2D point with x,y as properties
Extends
Implements
Methods
| Name | Description | |
|---|---|---|
| constructor(x: number = 0, y: number = 0): Point2d | Constructor for Point2d | |
| addForwardLeft(tangentFraction: number, leftFraction: number, vector: Vector2d, result?: Point2d): Point2d | Starting at this point, move along vector by tangentFraction of its length, and then |
|
| clone(result?: Point2d): Point2d | Return a new Point2d with x,y coordinates from this. | |
| crossProductToPoints(target1: Readonly<WritableXAndY>, target2: Readonly<WritableXAndY>): number | Returns the (scalar) cross product of vector from this to targetA and vector from this to targetB | |
| dotVectorsToTargets(targetA: Readonly<WritableXAndY>, targetB: Readonly<WritableXAndY>): number | Return the dot product of vector from this to targetA and vector from this to targetB | |
| forwardLeftInterpolate(tangentFraction: number, leftFraction: number, point: Readonly<WritableXAndY>): Point2d | Interpolate at tangentFraction between this instance and point, and then Move by leftFraction | |
| fractionOfProjectionToLine(startPoint: Point2d, endPoint: Point2d, defaultFraction: number = 0): number | Return the fractional coordinate of the projection of this instance x,y onto the | |
| interpolate(fraction: number, other: Readonly<WritableXAndY>, result?: Point2d): Point2d | Return a point interpolated between this point and the right param. | |
| interpolateXY(fractionX: number, fractionY: number, other: Readonly<WritableXAndY>, result?: Point2d): Point2d | Return a point with independent x,y fractional interpolation. | |
| minus(vector: Readonly<WritableXAndY>, result?: Point2d): Point2d | Return this point minus vector | |
| plus(vector: Readonly<WritableXAndY>, result?: Point2d): Point2d | Return point plus vector | |
| plus2Scaled(vectorA: Readonly<WritableXAndY>, scalarA: number, vectorB: Readonly<WritableXAndY>, scalarB: number, result?: Point2d): Point2d | Return point + vectorA * scalarA + vectorB * scalarB | |
| plus3Scaled(vectorA: Readonly<WritableXAndY>, scalarA: number, vectorB: Readonly<WritableXAndY>, scalarB: number, vectorC: Readonly<WritableXAndY>, scalarC: number, result?: Point2d): Point2d | Return point + vectorA * scalarA + vectorB * scalarB + vectorC * scalarC | |
| plusScaled(vector: Readonly<WritableXAndY>, scaleFactor: number, result?: Point2d): Point2d | Return point + vector * scalar | |
| plusXY(dx: number = 0, dy: number = 0, result?: Point2d): Point2d | Return point plus vector | |
| create(x: number = 0, y: number = 0, result?: Point2d): Point2d Static | Return a point (newly created unless result provided) with given x,y coordinates | |
| createAdd2Scaled(pointA: Readonly<WritableXAndY>, scaleA: number, pointB: Readonly<WritableXAndY>, scaleB: number, result?: Point2d): Point2d Static | Point2d equivalent of createAdd2Scaled. | |
| createAdd2ScaledXY(ax: number, ay: number, scaleA: number, bx: number, by: number, scaleB: number, result?: Point2d): Point2d Static | Point2d equivalent of createAdd2ScaledXY. | |
| createAdd3Scaled(pointA: Readonly<WritableXAndY>, scaleA: number, pointB: Readonly<WritableXAndY>, scaleB: number, pointC: Readonly<WritableXAndY>, scaleC: number, result?: Point2d): Point2d Static | Point2d equivalent of createAdd3Scaled. | |
| createAdd3ScaledXY(ax: number, ay: number, scaleA: number, bx: number, by: number, scaleB: number, cx: number, cy: number, scaleC: number, result?: Point2d): Point2d Static | Point2d equivalent of createAdd3ScaledXY. | |
| createFrom(xy: Readonly<WritableXAndY>, result?: Point2d): Point2d Static | Create (or optionally reuse) a Point2d from another object with fields x and y | |
| createZero(result?: Point2d): Point2d Static | Create a Point2d with both coordinates zero. | |
| fromJSON(json?: XYProps): Point2d Static | Set x and y from a JSON input such as [1,2] or {x:1, y:2} |
Inherited methods
| Name | Inherited from | Description |
|---|---|---|
| at(index: number): number Inherited | XY | Return the x,y component corresponding to 0,1 |
| distance(other: Readonly<WritableXAndY>): number Inherited | XY | Return the distance from this point to other |
| distanceSquared(other: Readonly<WritableXAndY>): number Inherited | XY | Return squared distance from this point to other |
| freeze(): Readonly<Point2d> Inherited | XY | Freeze this instance so it is read-only |
| indexOfMaxAbs(): number Inherited | XY | Return the index (0,1) of the x,y component with largest absolute value |
| isAlmostEqual(other: Readonly<WritableXAndY>, tol?: number): boolean Inherited | XY | Returns true if this and other have equal x,y parts within Geometry.smallMetricDistance. |
| isAlmostEqualMetric(other: Readonly<WritableXAndY>, distanceTol: number = Geometry.smallMetricDistance): boolean Inherited | XY | Returns true if x,y match other within metric tolerance |
| isAlmostEqualXY(x: number, y: number, tol?: number): boolean Inherited | XY | Returns true if this and other have equal x,y parts within Geometry.smallMetricDistance. |
| isExactEqual(other: Readonly<WritableXAndY>): boolean Inherited | XY | Returns true if the x,y components are exactly equal. |
| magnitude(): number Inherited | XY | Return the magnitude of the vector |
| magnitudeSquared(): number Inherited | XY | Return the squared magnitude of the vector. |
| maxAbs(): number Inherited | XY | Return the largest absolute value of any component |
| maxDiff(other: Readonly<WritableXAndY>): number Inherited | XY | Return the largest absolute distance between corresponding components |
| scaleInPlace(scale: number): this Inherited | XY | Multiply the x, y parts by scale, and return the instance. |
| set(x: number = 0, y: number = 0): void Inherited | XY | Set both x and y. |
| setAt(index: number, value: number): void Inherited | XY | Set value at index 0 or 1 |
| setFrom(other?: Readonly<WritableXAndY>): void Inherited | XY | Set both x and y from other. |
| setFromJSON(json?: XYProps): void Inherited | XY | Set x and y from a JSON input such as [1,2] or {x:1, y:2} |
| setZero(): void Inherited | XY | Set both x and y to zero |
| toJSON(): XYProps Inherited | XY | Return a json array [x,y] |
| toJSONXY(): XYProps Inherited | XY | Return a json object {x: 1, y:2} |
| unitVectorTo(other: Readonly<WritableXAndY>, result?: Vector2d): undefined | Vector2d Inherited | XY | Return a unit vector from this point to other |
| vectorTo(other: Readonly<WritableXAndY>, result?: Vector2d): Vector2d Inherited | XY | Return a (full length) vector from this point to other |
| crossProductToPoints(origin: Readonly<WritableXAndY>, targetA: Readonly<WritableXAndY>, targetB: Readonly<WritableXAndY>): number Static Inherited | XY | Cross product of vectors from origin to targets |
Inherited properties
| Name | Type | Inherited from | Description |
|---|---|---|---|
| isAlmostZero Accessor Inherited ReadOnly | boolean | XY | Returns true if the x,y components are both small by metric metric tolerance |
| isZero Accessor Inherited ReadOnly | boolean | XY | Return true if the x and y components are all exactly zero |
| x Inherited | number | XY | x component |
| y Inherited | number | XY | y component |
Defined in
- geometry3d/Point2dVector2d.ts Line 181
Last Updated: 24 October, 2025
Found something wrong, missing, or unclear on this page? Raise an issue in our repo.