Skip to content
Shapemetry

@huukhanhnguyen/geometry / catalog/axis2d

catalog/axis2d

Axis2d

const Axis2d: { angle: (px, py, dx, dy, other_px, other_py, other_dx, other_dy) => number; closestPoint: (axis, point) => Point2d; distanceToPoint: (axis, point) => number; equals: (px, py, dx, dy, other_px, other_py, other_dx, other_dy, tolerance) => boolean; fromPointDirection: (point, direction) => Axis2d; fromTwoPoints: (a, b) => Axis2d; intersect: (a, b) => Point2d | undefined; isParallel: (px, py, dx, dy, other_px, other_py, other_dx, other_dy, tolerance) => boolean; normal: (axis) => Vector2d; offset: (axis, distance) => Axis2d; project: (axis, point) => number; reflect: (axis, point) => Point2d; side: (px, py, dx, dy, x, y, tolerance) => number; signedDistance: (axis, point) => number; }

The generated wasm namespace plus the members that need a TS reshape. Re-exported from src/index.ts, where it shadows the generated Axis2d.

angle

angle: (px, py, dx, dy, other_px, other_py, other_dx, other_dy) => number = wasm.line2d_angle

Parameters

px

number

py

number

dx

number

dy

number

other_px

number

other_py

number

other_dx

number

other_dy

number

Returns

number

closestPoint

closestPoint: (axis, point) => Point2d

Point on axis closest to point.

Parameters

axis

Axis2d

point

Point2d

Returns

Point2d

distanceToPoint

distanceToPoint: (axis, point) => number

Perpendicular distance from point to axis.

Parameters

axis

Axis2d

point

Point2d

Returns

number

equals

equals: (px, py, dx, dy, other_px, other_py, other_dx, other_dy, tolerance) => boolean = wasm.line2d_equals

Parameters

px

number

py

number

dx

number

dy

number

other_px

number

other_py

number

other_dx

number

other_dy

number

tolerance

number

Returns

boolean

fromPointDirection

fromPointDirection: (point, direction) => Axis2d

Infinite 2D line through point along direction (unit-length crate-side).

Parameters

point

Point2d

direction

Vector2d

Returns

Axis2d

fromTwoPoints

fromTwoPoints: (a, b) => Axis2d

Infinite 2D line through points a and b (direction a → b).

Parameters

a

Point2d

b

Point2d

Returns

Axis2d

intersect

intersect: (a, b) => Point2d | undefined

Intersection point of two 2D axes; undefined when parallel.

Parameters

a

Axis2d

b

Axis2d

Returns

Point2d | undefined

isParallel

isParallel: (px, py, dx, dy, other_px, other_py, other_dx, other_dy, tolerance) => boolean = wasm.line2d_is_parallel

Parameters

px

number

py

number

dx

number

dy

number

other_px

number

other_py

number

other_dx

number

other_dy

number

tolerance

number

Returns

boolean

normal

normal: (axis) => Vector2d

Unit normal of axis (the direction rotated a quarter turn).

Parameters

axis

Axis2d

Returns

Vector2d

offset

offset: (axis, distance) => Axis2d

axis shifted distance along its normal.

Parameters

axis

Axis2d

distance

number

Returns

Axis2d

project

project: (axis, point) => number

Parameter of point's projection onto axis (signed distance along the unit direction from the axis's origin).

Parameters

axis

Axis2d

point

Point2d

Returns

number

reflect

reflect: (axis, point) => Point2d

Mirror image of point across axis.

Parameters

axis

Axis2d

point

Point2d

Returns

Point2d

side

side: (px, py, dx, dy, x, y, tolerance) => number = wasm.line2d_side

Parameters

px

number

py

number

dx

number

dy

number

x

number

y

number

tolerance

number

Returns

number

signedDistance

signedDistance: (axis, point) => number

Signed perpendicular distance from point to axis.

Parameters

axis

Axis2d

point

Point2d

Returns

number


closestPoint()

closestPoint(axis, point): Point2d

Point on axis closest to point.

Parameters

axis

Axis2d

point

Point2d

Returns

Point2d


distanceToPoint()

distanceToPoint(axis, point): number

Perpendicular distance from point to axis.

Parameters

axis

Axis2d

point

Point2d

Returns

number


fromPointDirection()

fromPointDirection(point, direction): Axis2d

Infinite 2D line through point along direction (unit-length crate-side).

Parameters

point

Point2d

direction

Vector2d

Returns

Axis2d


fromTwoPoints()

fromTwoPoints(a, b): Axis2d

Infinite 2D line through points a and b (direction a → b).

Parameters

a

Point2d

b

Point2d

Returns

Axis2d


intersect()

intersect(a, b): Point2d | undefined

Intersection point of two 2D axes; undefined when parallel.

Parameters

a

Axis2d

b

Axis2d

Returns

Point2d | undefined


normal()

normal(axis): Vector2d

Unit normal of axis (the direction rotated a quarter turn).

Parameters

axis

Axis2d

Returns

Vector2d


offset()

offset(axis, distance): Axis2d

axis shifted distance along its normal.

Parameters

axis

Axis2d

distance

number

Returns

Axis2d


project()

project(axis, point): number

Parameter of point's projection onto axis (signed distance along the unit direction from the axis's origin).

Parameters

axis

Axis2d

point

Point2d

Returns

number


reflect()

reflect(axis, point): Point2d

Mirror image of point across axis.

Parameters

axis

Axis2d

point

Point2d

Returns

Point2d


signedDistance()

signedDistance(axis, point): number

Signed perpendicular distance from point to axis.

Parameters

axis

Axis2d

point

Point2d

Returns

number

Last updated: 📖 6 min readEdit on GitHub