Skip to content

CircularClipping

Overview

Clipping arbitrary (degenerate, non-convex, self-intersecting, etc.) polygons to the inside/outside of a circle.

@author Jonathan Olson <jonathan.olson@colorado.edu>

Class CircularClipping

import { CircularClipping } from 'scenerystack/alpenglow';

Static Methods

binaryCircularClipEdges( edges : LinearEdge[], center : Vector2, radius : number, maxAngleSplit : number, inside : LinearEdge[], outside : LinearEdge[] )

Clips a polygon (represented by unsorted LinearEdges) by a circle. This will output both the inside and outside, appending LinearEdges to the given arrays.

@param edges - the edges of the polygon to clip @param center - the center of the circle @param radius - the radius of the circle @param maxAngleSplit - the maximum angle of a circular arc that will be converted into a linear edge @param inside - (OUTPUT) the edges that are inside the circle (will be appended to) @param outside - (OUTPUT) the edges that are outside the circle (will be appended to)

binaryCircularClipPolygon( polygons : Vector2[][], center : Vector2, radius : number, maxAngleSplit : number, inside : Vector2[][], outside : Vector2[][] )

Clips a polygon (represented by polygonal vertex lists) by a circle. This will output both the inside and outside, appending vertices to the arrays

@param polygons @param center - the center of the circle @param radius - the radius of the circle @param maxAngleSplit - the maximum angle of a circular arc that will be converted into a linear edge @param inside - (OUTPUT) the polygon that is inside the circle (will be appended to) @param outside - (OUTPUT) the polygon that is outside the circle (will be appended to)

binaryCircularTracingClipIterate( polygons : Vector2[][], center : Vector2, radius : number, maxAngleSplit : number, callback : BinaryClipCallback, polygonCompleteCallback : BinaryPolygonCompleteCallback )

Clips a polygon (represented by polygonal vertex lists) by a circle. This will output both the inside and outside, appending vertices to the arrays.

maxAngleSplit is the maximum angle of a circular arc that will be converted into a linear edge.

TODO: test this!

Source Code

See the source for CircularClipping.ts in the alpenglow repository.