This module contains all classes and methods used for geometric calculations. pLAySVG has one unconventional term it uses in its geometric calculations: ‘angal’. An angal is a fractional representation of an angle such that (using the clock metaphor) 0 is at 12:00, 0.25 is at 3:00, 0.5 is at 6:00, and 0.75 is at 9:00. An angal is always in range |0 - 1( as whole number portions of numbers are truncated in any calculations using them.
A 2D cartesian point
used to output fixed decimal string of length 5 (magic number) for SVG output
creates a radial grid with staggered layers as array containing arrays of Point objects where the returned array is accessed as follows: plots[layer][angle], where increase in layer moves out from center, increase in angle moves clockwise odd layer has point directly above center, even layer does not starting position for angle=0 varies based upon layer, spiraling clockwise
creates a radial grid with staggered layers as array containing arrays of Point where returns array is accessed as follows: plots[layer][angle], where increase in layer moves out from center, increase in angle moves clockwise
returns an array of equidistant points on a circle
creates a 2D array representing centres of triangles in a triangular grid bound by a triangle first dimension represents height second dmension represents horizontal position
creates a 2D array representing intersections of a triangular grid bound by a triangle first dimension represents height, second dimension represents horizontal position
calculate the length of a cubic bezier start:P1 control1:P2 control2:P3 end:P4
returns the sum of succesive distances between elements in the array points
generate a dictionary representing all possible irregular star polygons
Returns the angal defined for ABC (DUPLICATE ?)
Accepts 4 point objects representing a cubic bezier curve as described on wikipedia and a number of points n and returns an array of n CartesianPoints equally spaced along that curve
Accepts 4 point objects representing a quadradic bezier curve as described on wikipedia and a number of points n and returns an array of n CartesianPoints equally spaced along that curve
returns a point that is fract percent of the distance from pointA to pointB
get a point of specific distance along the line from pointA to pointB
returns an array of n points equally spaced along line AB
returns the itersection point for 2 lines if there exists one, calculations ported from Kevin Lindsey’s 2D.js library (switched to Inkscape extensions’ summersnight.py algorithm)
In a perspective drawing, things which are equally spaced apart in 3 dimensions, (i.e. mailboxes infront of houses on a road) get closer and closer together this algorithm, given a number of divisions and an angle at which the viewer is looking down, returns an array of ratios that represent how far each successive point is along the line towards the origin see The Illusion of Depth for an illustration. See in scripts/ platonicEarth.svg for an example of its use
returns a point that is the projection of pointB onto line that intersects lineA and lineB
calculate the length of a cubic bezier start:P1 control:P2 end:P3
Calculation as described in mathworld Reflection entry