LinearEdge¶
Overview¶
A line segment (between two points).
@author Jonathan Olson <jonathan.olson@colorado.edu>
Class LinearEdge¶
Constructor¶
new LinearEdge( startPoint : Vector2, endPoint : Vector2, containsFakeCorner )¶
Instance Methods¶
getLineIntegralArea() : number¶
If you take the sum of these for a closed polygon, it should be the area of the polygon.
getLineIntegralZero() : number¶
If you take the sum of these for a closed polygon, it should be zero (used to check computations).
serialize() : SerializedLinearEdge¶
toString() : string¶
Static Methods¶
fromPolygon( polygon : Vector2[] ) : LinearEdge[]¶
fromPolygons( polygons : Vector2[][] ) : LinearEdge[]¶
toPolygons( edges : LinearEdge[], epsilon ) : Vector2[][]¶
Returns a simplified version of the edges as a list of polygons.
NOTE: This is a low-performance method, mainly intended for debugging display.
withOppositesRemoved( edges : LinearEdge[], epsilon ) : LinearEdge[]¶
Detects edges that are exact opposites of other edges, and returns a new list of edges with those removed.
withOverlappingRemoved( edges : LinearEdge[], epsilon ) : LinearEdge[]¶
Detects ANY "opposite-direction" overlap between edges, and returns a new list of edges with those removed.
NOTE: This is a low-performance method, mainly intended for debugging display.
polygonsToShape( polygons : Vector2[][] ) : Shape¶
Returns a simplified version of the polygons as a kite Shape.
TODO: perhaps... move something like this to kite?
NOTE: This is a low-performance method, mainly intended for debugging display.
evaluateLineIntegralShoelaceArea( p0x : number, p0y : number, p1x : number, p1y : number ) : number¶
Cancelled subexpressions for fewer multiplications
evaluateLineIntegralArea( p0x : number, p0y : number, p1x : number, p1y : number ) : number¶
Without the subexpression cancelling
evaluateLineIntegralPartialCentroid( p0x : number, p0y : number, p1x : number, p1y : number ) : Vector2¶
If you take the sum of these for a closed polygon and DIVIDE IT by the area, it should be the centroid of the polygon.
evaluateLineIntegralZero( p0x : number, p0y : number, p1x : number, p1y : number ) : number¶
evaluateLineIntegralDistance( p0x : number, p0y : number, p1x : number, p1y : number ) : number¶
deserialize( obj : SerializedLinearEdge ) : LinearEdge¶
getPolygonArea( polygon : Vector2[] ) : number¶
getPolygonCentroid( polygon : Vector2[] ) : Vector2¶
getEdgesArea( clippedEdges : LinearEdge[] ) : number¶
evaluateClosestDistanceToOrigin( p0x : number, p0y : number, p1x : number, p1y : number ) : number¶
Given a line segment, returns the distance from the origin to the closest point on the line segment.
leftComparison( p0x : number, p0y : number, p1x : number, p1y : number, x : number, y : number ) : number¶
Tests if the point (x,y) is left/on/right of the infinite line determined by (p0x,p0y) and (p1x,p1y). Return: >0 for P2 left of the line through P0 and P1 =0 for P2 on the line <0 for P2 right of the line
windingContribution( p0x : number, p0y : number, p1x : number, p1y : number, x : number, y : number ) : number¶
Gets the winding contribution of an edge segment to a point with the Dan Sunday winding number algorithm.
See https://web.archive.org/web/20130126163405/http://geomalgorithms.com/a03-_inclusion.html
getWindingNumberEdges( edges : LinearEdge[], point : Vector2 ) : number¶
getWindingNumberPolygon( polygon : Vector2[], point : Vector2 ) : number¶
getWindingNumberPolygons( polygons : Vector2[][], point : Vector2 ) : number¶
addDistanceRange( startPoint : Vector2, endPoint : Vector2, point : Vector2, range : Range )¶
Given an edge defined by startPoint/endPoint, compute the range of distances from the given point to the edge, and add it to the range.
validateStartEndMatches( edges : LinearEdge[] )¶
Type SerializedLinearEdge¶
- startPoint:
- x: number
- y: number
- endPoint:
- x: number
- y: number
- containsFakeCorner: boolean
Source Code¶
See the source for LinearEdge.ts in the alpenglow repository.