Function isClockwise

  • This function is based on the idea that the cross product between v1 and v2 is norm(v1) * norm(v2) * sin(alpha) where alpha is the angle between the vectors. By going through each line segment as a vector and taking the cross product, we see if sin(alpha) is mostly positive or negative. Positive here meaning the vectors are turning right, negative meaning they are turning left.

    Parameters

    • lineSegments: LineSegment[]

      Array of line segments to check, note that they have to define a polygon by defining a closed shape (ie. the last line must end where the first line starts.).

    Returns boolean

Generated using TypeDoc