Constructor
new GeometricMath()
Methods
(static) arcCurvePoint(t, p0x, p0y, p1x, p1y, p2x, p2y) → {MoverPoint}
Returns the MoverPoint on the arc curve that is defined by the x/y pairs given. The MoverPoint returned is in relation to t (0 to .9) on the curve. This method creates and returns a new MoverPoint, to avoid that instead use updateArcCurvePath with a premade MoverPoint.
Name | Type | Description |
---|---|---|
t |
Number | translation on the path from which to get the one point; 0 to .9. |
p0x |
Number | x position of first point in curve path |
p0y |
Number | y position of first point in curve path |
p1x |
Number | x position of middle point in curve path |
p1y |
Number | y position of middle point in curve path |
p2x |
Number | x position of last point in curve path |
p2y |
Number | y position of last point in curve path |
- Type
- MoverPoint
(static) getArcCurvePath(p0, p1, p2, amountOfPathPoints) → {Array}
Returns an Array of MoverPoints that make up the arc defined by the points given. p0 is the first leftmost point of the arc, p1 is the middle of the arc, and p2 is the end of the arc.
Name | Type | Description |
---|---|---|
p0 |
MoverPoint | the first MoverPoint of the arc path |
p1 |
MoverPoint | the middle MoverPoint of the arc path |
p2 |
MoverPoint | the last MoverPoint of the arc path |
amountOfPathPoints |
Number | the number of points along the path to return. |
- Type
- Array
(static) getHermiteCurvePath() → {Array}
Returns an Array of MoverPoints that make up the hermite (wave) path as defined by the points given.
- Type
- Array
(static) getMoverPointsOnCircle(circleCenter, circleRadius, numberOfPoints) → {Array}
Returns an Array of MoverPoints that make up a circle as defined by circleCenter, and circleRadius
Name | Type | Description |
---|---|---|
circleCenter |
MoverPoint | the center point of the circle |
circleRadius |
Number | the radius of the circle |
numberOfPoints |
Number | the amount of points to get |
- Type
- Array
(static) getRawArcCurvePath(p0x, p0y, p1x, p1y, p2x, p2y, amountOfPathPoints, prePath) → {Array|Number}
Returns an Array of x and y pairs that make up the locations of each point along the path defined by the x/y pairs given. This is the most efficient method to use to obtain a arc curve path, then loop through the array by 2 to use each x y location.
Name | Type | Description |
---|---|---|
p0x |
Number | the x position of the first point. |
p0y |
Number | the y position of the first point. |
p1x |
Number | the x position of the middle point. |
p1y |
Number | the y position of the middle point. |
p2x |
Number | the x position of the last point. |
p2y |
Number | the y position of the last point. |
amountOfPathPoints |
Number | the amount of points to calculate. |
prePath |
Array | a predefined Array to hold the path. |
- Type
- Array | Number
(static) getRawHermiteCurvePath() → {Array|Number}
Returns or updates an Array of x/y pairs that make up the hermite (wave) path as defined by the x/y pairs given.
- Type
- Array | Number
(static) getRawPointsOnCircle(circleCenterX, circleCenterY, circleRadius, numberOfPoints) → {Array}
Returns an Array of the x/y pairs that define each point along the circle defined by circleCenterX/Y circleRaidus and numberOfPoints.
Name | Type | Description |
---|---|---|
circleCenterX |
Number | the x position of the circles center |
circleCenterY |
Number | the y position of the circles center |
circleRadius |
Number | the radious of the circle |
numberOfPoints |
Number | the amount of points to get |
- Type
- Array
(static) hermiteCurvePoint(t, p0x, p0y, t0x, t0y, p1x, p1y, t1x, t1y) → {MoverPoint}
Returns the point on the hermite (wave) curve as defined by t and the x/y pairs given. Creates and returns a new MoverPoint.
Name | Type | Description |
---|---|---|
t |
Number | |
p0x |
Number | the x position of the first point. |
p0y |
Number | the y position of the first point. |
t0x |
Number | the x position of the middle point. |
t0y |
Number | the y position of the middle point. |
p1x |
Number | the x position of the last point. |
p1y |
Number | the y position of the last point. |
t1x |
Number | the x position of the middle point. |
t1y |
Number | the y position of the middle point. |
- Type
- MoverPoint
(static) isPowerOfTwo(x) → {Boolean}
Returns true if the number given is a power of 2.
Name | Type | Description |
---|---|---|
x |
Number | The Number to check. |
- Type
- Boolean
(static) lineIntersectionPoint(a, b, c, d) → {MoverPoint}
Returns the point at which the lines interset or null.
Name | Type | Description |
---|---|---|
a |
beginning point of line one |
|
b |
ending point of line one |
|
c |
beginning point of line two |
|
d |
ending point of line two |
- Type
- MoverPoint
(static) lineIntersectionTest(a, b, c, d) → {Boolean}
Returns true if the two lines intersect.
Name | Type | Description |
---|---|---|
a |
beginning point of line one |
|
b |
ending point of line one |
|
c |
beginning point of line two |
|
d |
ending point of line two |
- Type
- Boolean
(static) mergeArrays(a1, a2) → {Array}
Merges two or more Arrays into a1 and returns a1.
Name | Type | Description |
---|---|---|
a1 |
Array | The Array that should get the other Arrays values added to it at the end |
a2 |
Array | The first Array whos values will get added to the end of a1, any other Arrays passed will keep getting added to the end. |
One Array containing the values of all the Arrays given.
- Type
- Array
(static) rectanglesIntersect(r1, r2) → {Boolean}
Returns true if the two given Rectangles intersect.
- Type
- Boolean
(static) rectanglesOverlapAmount(r1, r2) → {Number}
Returns the amount of overlap between two Rectangles, if any.
- Type
- Number
(static) splice(arr, index)
Splices the given Array at the given index, without returning anything.
Name | Type | Description |
---|---|---|
arr |
Array | The Array to splice |
index |
Number | The index at which to splice the Array. |
(static) testForPointInArea(p, left, right, top, bottom) → {Boolean}
Returns true if the given point is inside the area defined by left top right and bottom cords.
Name | Type | Description |
---|---|---|
p |
MoverPoint | the point to check if its in the given area. |
left |
Number | the left (x) position of the area |
right |
Number | the right (x+width) position of the area |
top |
Number | the top (y) position of the area |
bottom |
Number | the bottom (y+height) position of the area |
- Type
- Boolean
(static) testForPointInCircle(circlePosition, circleRadius, pointToTest) → {Boolean}
Returns true if the given point is inside the circle defined by circlePosition and circleRadius
Name | Type | Description |
---|---|---|
circlePosition |
MoverPoint | the position of the circle (its center) |
circleRadius |
Number | the radius of the circle |
pointToTest |
MoverPoint | the point to test and see if its inside the circles area. |
- Type
- Boolean
(static) updateArcCurvePath(path, p0, p1, p2)
Updates the Array path given with the MoverPoints that make up the arc defined by the points given. A path should first be made using the GeometricMath.getArcCurvePath method.
Name | Type | Description |
---|---|---|
path |
Array | an Array of MoverPoints to update |
p0 |
MoverPoint | the first point in the arc curve path |
p1 |
MoverPoint | the middle point in the arc curve path |
p2 |
MoverPoint | the last point in the arc curve path |
(static) updateArcCurvePoint(point, t, p0x, p0y, p1x, p1y, p2x, p2y)
Updates the given MoverPoint on the arc curve defined by the x/y pairs given. The update is based on t, which is a 0 to .9 value, the amount of points the path has being 1. The path is defined by p0x...p2y.
Same as the arcCurvePoint method except that you pass in a pre made MoverPoint that gets updated.
Name | Type | Description |
---|---|---|
point |
MoverPoint | The MoverPoint to store the point on the path. |
t |
Number | translation on the path from which to get the one point; 0 to .9. |
p0x |
Number | x position of first point in curve path |
p0y |
Number | y position of first point in curve path |
p1x |
Number | x position of middle point in curve path |
p1y |
Number | y position of middle point in curve path |
p2x |
Number | x position of last point in curve path |
p2y |
Number | y position of last point in curve path |