Skip to content

@ue-too/math / index / directionAlignedToTangent

関数: directionAlignedToTangent()

directionAlignedToTangent(direction, tangent): boolean

定義: index.ts:824

Checks if a direction vector is aligned with a tangent vector.

パラメータ

direction

Point

Direction vector to check

tangent

Point

Tangent vector reference

戻り値

boolean

True if direction aligns with tangent (within 90 degrees)

Remarks

Returns true if the direction is within 90 degrees of either the tangent or its reverse. Useful for determining if movement is along a path.

typescript
const direction = { x: 1, y: 0 };
const tangent = { x: 1, y: 0.1 }; // Slightly rotated
directionAlignedToTangent(direction, tangent); // true

const perpendicular = { x: 0, y: 1 };
directionAlignedToTangent(perpendicular, tangent); // false