Skip to content

@ue-too/math / samePoint

Function: samePoint()

samePoint(a, b, precision?): boolean

Defined in: index.ts:864

Checks if two points are approximately at the same location.

Parameters

a

Point

First point

b

Point

Second point

precision?

number

Optional tolerance for coordinate comparison

Returns

boolean

True if both x and y coordinates are within precision

Remarks

Uses approximatelyTheSame for coordinate comparison. For exact equality, use PointCal.isEqual instead.

Example

typescript
const a = { x: 1.0, y: 2.0 };
const b = { x: 1.0000001, y: 2.0000001 };
samePoint(a, b); // true (within default precision)

const c = { x: 1.1, y: 2.0 };
samePoint(a, c); // false