-
Notifications
You must be signed in to change notification settings - Fork 865
Geometry
In order to create geometry shapes you need to include graphie-geometry.
That gives you two classes you can use, Triangle and Quadrilateral. Their code is currently separate, but they will soon be combined. At the moment Quadrilateral lacks some features of Triangles.
###Triangle
Triangle( center, angles, scale, labels, points )
Center
Useful Triangle/Quadrilateral methods:
draw(): Renders the triangle inside graphie
drawLabels(): Renders the labels inside graphie
The following are only implemented for triangles atm 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 array with [ x, y, boolean which says whether the intersection is inside