-
Notifications
You must be signed in to change notification settings - Fork 1
Geometry
In order to create geometry shapes you need to include graphie-geometry.
There are two classes you can use, Triangle and Quadrilateral.
###Triangle
Triangle( center, angles, scale, labels, points )
###Useful Triangle/Quadrilateral methods:
-
draw()
- Renders the triangle inside graphie -
drawLabels()
- Renders the labels inside graphie -
boxOut( pol, amount, type )
- If the triangle intersects the given polygon, it will translate by the given amount until no longer so. Useful for putting multiple shapes on screen an making sure they do not overlap. Also useful for making sure the triangle fits inside graphie bounds -
rotate( amount )
- Rotate the triangle by the given amount in degrees -
translate( [x, y ] )
- Translate the triangle by the given point
###Various helper methods
-
lineLength( line )
-
dotProduct( a,b )
-
isPointOnLineSegment( line, point, precision )
-
findPointsOnLine( line, [ points ] )
- Returns an array of all the points that were on the given line -
areIntersecting( polygon1, polygon2 )
- Only works for convex polygons -
findIntersection( line1, line2 )
- Returns an intersection of two lines, and whether that point is inside both line segments¬ -
checkDuplicate( arr, el )
- Checks whether there are duplicate points in an array¬ -
pointLineDistance( p, l )
-
reflectPoint( l, p )
- Reflects a point p over line l -
linePathIntersection( l, p )
- Returns an array of points where a path intersects a line -
clearArray( array, indices )
- Return an array that only keeps elements with specified indices and makes all others "" -
mergeArray( arr1, arr2 )
- Puts element from arr2 into arr1 if element in arr1 is ""
For example mergeArray(clearArray( [ "x", "x", "x" ], [ ANGLE ] ), ["a","b","c" ] )
, where ANGLE is 1, gives labels for a triangle [ "a", "x", "c" ]¬