jakke-graphics-ts
    Preparing search index...

    Function computeOBB2d

    • Computes the minimum area oriented bounding box (OBB) for a set of 2D vertices. The function projects the vertices onto their convex hull, iterates over each edge, rotates the hull so the edge aligns with the x-axis, and finds the bounding box with the smallest area. The resulting OBB is returned as four vertices sorted counterclockwise starting from the bottom-left corner.

      Parameters

      • vertices: Vertex3d[]

        An array of Vertex3d objects representing the 2D points (z is ignored).

      Returns { p0: Vertex3d; p1: Vertex3d; p2: Vertex3d; p3: Vertex3d }

      An object containing the four vertices (p0, p1, p2, p3) of the minimum area OBB, sorted counterclockwise starting from the bottom-left vertex.