Skip to content
This repository was archived by the owner on May 11, 2021. It is now read-only.

Geometry

igorT edited this page Oct 2, 2011 · 13 revisions

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 )

###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 array with [ x, y, boolean which says whether the intersection is inside

Clone this wiki locally