## 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`

• object

### Methods

Name Description
constructor(x: number = 0, y: number = 0): Protected
distance(other: XAndY): number Return the distance from this point to other
distanceSquared(other: XAndY): number Return squared distance from this point to other
freeze(): void Freeze this instance (and its deep content) so it can be considered read-only
isAlmostEqual(other: XAndY, tol?: number): boolean Returns true if this and other have equal x,y parts within Geometry.smallMetricDistance.
isAlmostEqualMetric(other: XAndY): 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: XAndY): 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: XAndY): number Return the largest absolute distance between corresponding components
set(x: number = 0, y: number = 0): void Set both x and y.
setFrom(other?: XAndY): void Set both x and y from other.
setFromJSON(json?: XYProps): void Set x and y from a JSON source such as `[1,2]` or `{x:1, y:2}`
setZero(): void Set both x and y to zero
toJSON(): return a json array `[x,y]`
toJSONXY(): return a json object `{x: 1, y:2}`
unitVectorTo(target: XAndY, result?: Vector2d): Vector2d | undefined Return a unit vector from this point to other
vectorTo(other: XAndY, result?: Vector2d): Return a (full length) vector from this point to other
crossProductToPoints(origin: XAndY, targetA: XAndY, targetB: XAndY): 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

Last Updated: 20 September, 2019