@equinor/videx-linear-algebra
    Preparing search index...

    Function isPointInTriangle

    • Determines if a point lies within a triangle in 2D space. Inspired by: https://stackoverflow.com/a/9755252/5946596

      Parameters

      • p: VectorLike

        The point to check [x, y].

      • a: VectorLike

        Vertex A of the triangle [x, y].

      • b: VectorLike

        Vertex B of the triangle [x, y].

      • c: VectorLike

        Vertex C of the triangle [x, y].

      • inwardAdjustment: number = 1e-6

        Scales inward adjustment relative to distance for edge handling (default: 1e-6).

      Returns boolean

      True if the point is inside the triangle or on one of its edges; otherwise, false.

      isPointInTriangle([0.25, 0.25], [0, 0], [1, 0], [0, 1]); // Returns true