jakke-graphics-ts
    Preparing search index...

    Function footingPointOnPolyline2d

    • Finds the closest footing point on a 2D polyline to a given point.

      Iterates through each segment of the polyline and computes the perpendicular foot point from the input point. Returns the best candidate with the shortest distance to the input point, along with its position on the polyline, the corresponding segment, and all available candidate factors.

      Parameters

      • polyline: Polyline2d

        The polyline to evaluate, represented as an array of 2D vertices.

      • pt: Vertex2d

        The 2D point for which to find the closest footing point on the polyline.

      • withinCurve: boolean = false

        If true, restricts the search to points strictly within segments (not at vertices).

      Returns
          | undefined
          | {
              availableFactors: Polyline2dEvaluationFactor[];
              lineSegment: Line;
              pt: Vertex2d;
              t: number;
          }

      An object containing:

      • pt: The closest point on the polyline (2D).
      • t: The normalized parameter (0 to 1) representing the position along the polyline.
      • lineSegment: The segment of the polyline where the footing point lies.
      • availableFactors: All candidate factors considered during evaluation. Returns undefined if no valid footing point is found.