Geometry
Functions
Center Point
Returns the center point of the circle.
Parameters:
Name | Type | Description |
---|---|---|
c | Circle | The circle to get the center point |
Return Type: Point 2d
Signatures:
Circle At
Circle At
Returns a circle at the indicated point and radius.
Parameters:
Name | Type | Description |
---|---|---|
pt | Point 2d | The location of the center of the circle |
radius | Double | The radius of the circle |
Return Type: Circle
Signatures:
Circle At
Returns a circle at the indicated point and radius.
Parameters:
Name | Type | Description |
---|---|---|
x | Double | The x location of the circle |
y | Double | The y location of the circle |
radius | Double | The radius of the circle |
Return Type: Circle
Signatures:
Circle Radius
Returns the circle radius.
Parameters:
Name | Type | Description |
---|---|---|
c | Circle | The circle |
Return Type: Float
Signatures:
Circle Triangle Intersect
Circle Triangle Intersect
Detects if a circle intersects with a triangle.
Parameters:
Name | Type | Description |
---|---|---|
c | Circle | The circle to test |
tri | Triangle | The triangle to test |
Return Type: Boolean
Signatures:
Circle Triangle Intersect
Detects if a circle intersects with a triangle. The closest point on the triangle to the circle is assigned to p, even if the circle and triangle do not intersect. If the centre of the circle is inside the triangle, the point assigned to p is the centre of the circle.
Parameters:
Name | Type | Description |
---|---|---|
c | Circle | The circle to test |
tri | Triangle | The triangle to test |
p | Point 2d | The point to set to the closest point on the triangle to the circle |
Return Type: Boolean
Signatures:
Circle X
Returns the circle x value.
Parameters:
Name | Type | Description |
---|---|---|
c | Circle | The circle |
Return Type: Float
Signatures:
Circle Y
Returns the circle y value.
Parameters:
Name | Type | Description |
---|---|---|
c | Circle | The circle |
Return Type: Float
Signatures:
Circles Intersect
Circles Intersect
Detects if two circles intersect. This can be used to detect collisions between bounding circles.
Parameters:
Name | Type | Description |
---|---|---|
c1 | Circle | The circle to test if intersects with c2 |
c2 | Circle | The circle to test if intersects with c1 |
Return Type: Boolean
Signatures:
Circles Intersect
Detects if two circles intersect. This can be used to detect collisions between bounding circles. The circle data is passed in as individual values.
Parameters:
Name | Type | Description |
---|---|---|
c1_x | Double | the x location of the first circle |
c1_y | Double | the y location of the first circle |
c1_radius | Double | the radius of the first circle |
c2_x | Double | the x location of the second circle |
c2_y | Double | the y location of the second circle |
c2_radius | Double | the radius of the second circle |
Return Type: Boolean
Signatures:
Closest Point On Circle
The closest point on the circle to the given point.
Parameters:
Name | Type | Description |
---|---|---|
from_pt | Point 2d | The point to test from |
c | Circle | The circle you want to get a point on its circumference |
Return Type: Point 2d
Signatures:
Closest Point On Line From Circle
Returns the closest point on a line to a circle.
Parameters:
Name | Type | Description |
---|---|---|
c | Circle | The circle |
l | Line | The line |
Return Type: Point 2d
Signatures:
Closest Point On Rect From Circle
Returns the closest point on a rectangle to a circle.
Parameters:
Name | Type | Description |
---|---|---|
c | Circle | The circle |
rect | Rectangle | The rectangle |
Return Type: Point 2d
Signatures:
Closest Point On Triangle From Circle
Calculates the closest point on a triangle to a circle. If the circle and triangle do not intersect, the closest point on the triangle to the circle is returned. If the circle and triangle do intersect, the center of the circle is returned.
Parameters:
Name | Type | Description |
---|---|---|
c | Circle | The circle to test |
tri | Triangle | The triangle to test |
Return Type: Point 2d
Signatures:
Distant Point On Circle
The furthest point on the circle to the given point.
Parameters:
Name | Type | Description |
---|---|---|
pt | Point 2d | The point to test from |
c | Circle | The circle you want to get a point on its circumference |
Return Type: Point 2d
Signatures:
Distant Point On Circle Heading
Determines the opposite side of a circle given a collision point and a heading.
Parameters:
Name | Type | Description |
---|---|---|
pt | Point 2d | The point from which the test is being made |
c | Circle | The circle |
heading | Vector 2d | The direction the point is heading |
opposite_pt | Point 2d | After the call, this is set to the point on the opposite side of the circle from pt when it is heading in the given direction. |
Return Type: Boolean
Signatures:
Ray Circle Intersect Distance
Calculates the distance from a ray cast from a point to a given circle.
Parameters:
Name | Type | Description |
---|---|---|
ray_origin | Point 2d | The origin of the ray |
ray_heading | Vector 2d | The direction of the ray |
c | Circle | The circle being tested |
Return Type: Float
Signatures:
Tangent Points
Returns the two tangent points on the circle given the indicated point.
Parameters:
Name | Type | Description |
---|---|---|
from_pt | Point 2d | The source point |
c | Circle | The circle |
p1 | Point 2d | If this returns true, then p1 contains one of the points |
p2 | Point 2d | If this returns true, then p2 contains one of the points |
Return Type: Boolean
Signatures:
Widest Points
Calculates the two points on a circles radius that lie along the given vector. This represents the points on the circle when the vector is placed at the circle’s center point.
Parameters:
Name | Type | Description |
---|---|---|
c | Circle | The circle |
along | Vector 2d | The vector representing the line along which the points lie. |
pt1 | Point 2d | After the call, this is set to one of the widest points |
pt2 | Point 2d | After the call, this is set to one of the widest points |
Signatures:
Cosine
Returns the cosine of the supplied angle (in degrees).
Parameters:
Name | Type | Description |
---|---|---|
degrees | Float | The angle in degrees |
Return Type: Float
Signatures:
Sine
Returns the sine of the supplied angle (in degrees).
Parameters:
Name | Type | Description |
---|---|---|
degrees | Float | The angle in degrees |
Return Type: Float
Signatures:
Tangent
Returns the tangent of the supplied angle (in degrees).
Parameters:
Name | Type | Description |
---|---|---|
degrees | Float | The angle in degrees |
Return Type: Float
Signatures:
Closest Point On Line
Gets the closest point on the line to a given point.
Parameters:
Name | Type | Description |
---|---|---|
from_pt | Point 2d | The point to test (usually somewhere near the line) |
l | Line | The line |
Return Type: Point 2d
Signatures:
Closest Point On Lines
Get the point closest to from pt
that is on one of the supplied lines.
Parameters:
Name | Type | Description |
---|---|---|
from_pt | Point 2d | The point to test |
lines | Vector | The lines to check |
line_idx | Integer | After the call this will store the index of the line that had the matching point. |
Return Type: Point 2d
Signatures:
Line From
Line From
Create a line from one point to another.
Parameters:
Name | Type | Description |
---|---|---|
start | Point 2d | The start of the line |
end_pt | Point 2d | The end of the line |
Return Type: Line
Signatures:
Line From
Creates a line that starts at a point, and follows a given vector.
Parameters:
Name | Type | Description |
---|---|---|
start | Point 2d | The start of the line |
offset | Vector 2d | The offset to the end of the line |
Return Type: Line
Signatures:
Line From
Gets a line that goes from the origin and ends at the end of the vector.
Parameters:
Name | Type | Description |
---|---|---|
v | Vector 2d | The offset from the origin for the end of the line |
Return Type: Line
Signatures:
Line From
Create a line from one point to another.
Parameters:
Name | Type | Description |
---|---|---|
x1 | Double | The x value of the start of the line |
y1 | Double | The y value of the start of the line |
x2 | Double | The x value of the end of the line |
y2 | Double | The y value of the end of the line |
Return Type: Line
Signatures:
Line Intersection Point
Returns the point at which two lines would intersect. This point may lie past the end of one or both lines.
Parameters:
Name | Type | Description |
---|---|---|
line1 | Line | The first line |
line2 | Line | The other line |
pt | Point 2d | The resulting point where they intersect |
Return Type: Boolean
Signatures:
Line Intersects Circle
Returns true if the line intersects the circle.
Parameters:
Name | Type | Description |
---|---|---|
l | Line | The line |
c | Circle | The circle |
Return Type: Boolean
Signatures:
Line Intersects Lines
Returns true if the line intersects any of the lines.
Parameters:
Name | Type | Description |
---|---|---|
l | Line | The line to check |
lines | Vector | The lines to check against |
Return Type: Boolean
Signatures:
Line Intersects Rect
Returns true if the line intersects the rectangle.
Parameters:
Name | Type | Description |
---|---|---|
l | Line | The line |
rect | Rectangle | The rectangle |
Return Type: Boolean
Signatures:
Line Length
Returns the length of a line.
Parameters:
Name | Type | Description |
---|---|---|
l | Line | The line |
Return Type: Float
Signatures:
Line Length Squared
Returns the squared length of the line. You can also get the Line Length
.
Parameters:
Name | Type | Description |
---|---|---|
l | Line | The line |
Return Type: Float
Signatures:
Line Mid Point
Returns the center point of the line.
Parameters:
Name | Type | Description |
---|---|---|
l | Line | The line |
Return Type: Point 2d
Signatures:
Line Normal
The line normal (a perpendicular vector).
Parameters:
Name | Type | Description |
---|---|---|
l | Line | The line |
Return Type: Vector 2d
Signatures:
Line To String
Returns a text description of the line.
Parameters:
Name | Type | Description |
---|---|---|
ln | Line | The line |
Return Type: String
Signatures:
Lines From
Lines From
Returns an array of lines from a supplied rectangle.
Parameters:
Name | Type | Description |
---|---|---|
rect | Rectangle | The rectangle to get the lines from |
Return Type: Vector
Signatures:
Lines From
Returns an array of lines from the details in the triangle.
Parameters:
Name | Type | Description |
---|---|---|
t | Triangle | The triangle |
Return Type: Vector
Signatures:
Lines Intersect
Returns true if the two lines intersect.
Parameters:
Name | Type | Description |
---|---|---|
l1 | Line | The first line |
l2 | Line | The other line |
Return Type: Boolean
Signatures:
Point At
Returns a point at the given location.
Parameters:
Name | Type | Description |
---|---|---|
x | Double | The x value of the coordinate |
y | Double | The y value of the coordinate |
Return Type: Point 2d
Signatures:
Point At Origin
Returns a point representing the origin.
Return Type: Point 2d
Signatures:
Point In Circle
Point In Circle
Returns true if the point pt
is in the circle c
.
Parameters:
Name | Type | Description |
---|---|---|
pt | Point 2d | The point to test |
c | Circle | The circle to check |
Return Type: Boolean
Signatures:
Point In Circle
Return true if the point is in the circle.
Parameters:
Name | Type | Description |
---|---|---|
ptx | Double | the x value of the point |
pty | Double | the y value of the point |
cx | Double | the x value of the centre of the circle |
cy | Double | the y value of the centre of the circle |
radius | Double | the radius of the circle |
Return Type: Boolean
Signatures:
Point In Quad
Tests if a point is in a quad.
Parameters:
Name | Type | Description |
---|---|---|
pt | Point 2d | The point to test. |
q | Quad | The quad to check if the point is within. |
Return Type: Boolean
Signatures:
Point In Rectangle
Point In Rectangle
Returns true if point pt
is in the Rectangle rect
.
Parameters:
Name | Type | Description |
---|---|---|
pt | Point 2d | The point to test |
rect | Rectangle | The rectangle to check |
Return Type: Boolean
Signatures:
Point In Rectangle
Returns true if the point is within the bounds of a Rectangle.
Parameters:
Name | Type | Description |
---|---|---|
ptx | Double | the x value of the point |
pty | Double | the y value of the point |
rect_x | Double | x value of the rectangle |
rect_y | Double | y value of the rectangle |
rect_width | Double | width of the rectangle |
rect_height | Double | height of the rectangle |
Return Type: Boolean
Signatures:
Point In Triangle
Returns true if the point pt
is in the Triangle tri
.
Parameters:
Name | Type | Description |
---|---|---|
pt | Point 2d | The point to test |
tri | Triangle | The triangle to check |
Return Type: Boolean
Signatures:
Point Line Distance
Returns the distance from a point to a line.
Parameters:
Name | Type | Description |
---|---|---|
pt | Point 2d | The point |
l | Line | The line |
Return Type: Float
Signatures:
Point Offset By
Calculate the Point 2d
that is offset from the start_point
by the offset
Parameters:
Name | Type | Description |
---|---|---|
start_point | Point 2d | The starting point |
offset | Vector 2d | The distance and direction to move |
Return Type: Point 2d
Signatures:
Point Offset From Origin
Returns the point offset from the origin by the provided vector.
Parameters:
Name | Type | Description |
---|---|---|
offset | Vector 2d | The distance and direction to move |
Return Type: Point 2d
Signatures:
Point On Line
Point On Line
Returns true if point pt
is on the line l
.
Parameters:
Name | Type | Description |
---|---|---|
pt | Point 2d | The point to test |
l | Line | The line to check |
Return Type: Boolean
Signatures:
Point On Line
Returns true when the point pt
is on the line l
. The proximity value is used to set the sensitivity — higher values effectively make the line thicker.
Parameters:
Name | Type | Description |
---|---|---|
pt | Point 2d | The point to test |
l | Line | The line to check |
proximity | Float | The sensitivity to allow close approximities |
Return Type: Boolean
Signatures:
Point Point Angle
Returns the angle between two points in degrees.
Parameters:
Name | Type | Description |
---|---|---|
pt1 | Point 2d | The first point |
pt2 | Point 2d | The other point |
Return Type: Float
Signatures:
Point Point Distance
Returns the distance between two points.
Parameters:
Name | Type | Description |
---|---|---|
pt1 | Point 2d | The first point |
pt2 | Point 2d | The other point |
Return Type: Float
Signatures:
Point To String
Get a text description of the Point 2d
.
Parameters:
Name | Type | Description |
---|---|---|
pt | Point 2d | The point details |
Return Type: String
Signatures:
Random Bitmap Point
Returns a random point within the bounds of the bitmap.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap |
Return Type: Point 2d
Signatures:
Random Screen Point
Returns a random point on the current window.
Return Type: Point 2d
Signatures:
Random Window Point
Returns a random point on the provided window.
Parameters:
Name | Type | Description |
---|---|---|
wind | Window | The window |
Return Type: Point 2d
Signatures:
Same Point
Returns True of pt1
is at the same point as pt2
. This checks at an integer level, indicating the two points refer to the same pixel.
Parameters:
Name | Type | Description |
---|---|---|
pt1 | Point 2d | The first point |
pt2 | Point 2d | The other point |
Return Type: Boolean
Signatures:
Quad From
Quad From
Returns a quad from the passed in points.
Parameters:
Name | Type | Description |
---|---|---|
p1 | Point 2d | The top left of the quad. |
p2 | Point 2d | The top right of the quad |
p3 | Point 2d | The bottom left of the quad |
p4 | Point 2d | The bottom right of the quad |
Return Type: Quad
Signatures:
Quad From
Returns a quad from the x-y points of a given recatangle
Parameters:
Name | Type | Description |
---|---|---|
rect | Rectangle | The rectangle to convert to a quad |
Return Type: Quad
Signatures:
Quad From
Returns a quad from the rectangle, then applies the transformation to the quads points.
Parameters:
Name | Type | Description |
---|---|---|
rect | Rectangle | The rectangle to transform to a quad. |
transform | Matrix 2d | A transform to apply to the resulting quad. |
Return Type: Quad
Signatures:
Quad From
Returns a quad for the passed in x & y points.
Parameters:
Name | Type | Description |
---|---|---|
x_top_left | Double | X coordinate of the top left of the quad |
y_top_left | Double | Y coordinate of the top left of the quad |
x_top_right | Double | X coordinate of the top right of the quad |
y_top_right | Double | Y coordinate of the top right of the quad |
x_bottom_left | Double | X coordinate of the bottom left of the quad |
y_bottom_left | Double | Y coordinate of the bottom left of the quad |
x_bottom_right | Double | X coordinate of the bottom right of the quad |
y_bottom_right | Double | Y coordinate of the bottom right of the quad |
Return Type: Quad
Signatures:
Quads Intersect
Returns true if two quads intersect.
Parameters:
Name | Type | Description |
---|---|---|
q1 | Quad | The first quad |
q2 | Quad | The second quad |
Return Type: Boolean
Signatures:
Set Quad Point
Change a point in a quad.
Parameters:
Name | Type | Description |
---|---|---|
q | Quad | The quad to change |
idx | Integer | The index of the point: 0 is top left, 1 is top right, 2 is bottom left, and 3 is bottom right |
value | Point 2d | The new value for that point in the quad |
Signatures:
Triangles From
Returns the two triangles that make up a quad in a vector.
Parameters:
Name | Type | Description |
---|---|---|
q | Quad | The quad |
Return Type: Vector
Signatures:
Inset Rectangle
Return a rectangle that is inset an amount from a given rectangle.
Parameters:
Name | Type | Description |
---|---|---|
rect | Rectangle | The rectangle to inset |
inset_amount | Float | The amount to inset the rectangle |
Return Type: Rectangle
Signatures:
Intersection
Returns a rectangle that represents the intersection of two rectangles.
Parameters:
Name | Type | Description |
---|---|---|
rect1 | Rectangle | The first rectangle |
rect2 | Rectangle | The second rectangle |
Return Type: Rectangle
Signatures:
Rectangle Around
Rectangle Around
Returns a rectangle that surrounds a given circle
Parameters:
Name | Type | Description |
---|---|---|
c | Circle | The circle |
Return Type: Rectangle
Signatures:
Rectangle Around
Returns a rectangle that surrounds a given line segment
Parameters:
Name | Type | Description |
---|---|---|
l | Line | The line |
Return Type: Rectangle
Signatures:
Rectangle Around
Returns a rectangle that surrounds a given quad.
Parameters:
Name | Type | Description |
---|---|---|
q | Quad | The quad |
Return Type: Rectangle
Signatures:
Rectangle Around
Returns a rectangle that surrounds a given triangle
Parameters:
Name | Type | Description |
---|---|---|
t | Triangle | The triangle |
Return Type: Rectangle
Signatures:
Rectangle Bottom
The location of the bottom of the rectangle.
Parameters:
Name | Type | Description |
---|---|---|
rect | Rectangle | The rectangle. |
Return Type: Float
Signatures:
Rectangle Center
Returns the center point of a given rectangle
Parameters:
Name | Type | Description |
---|---|---|
rect | Rectangle | The rectangle |
Return Type: Point 2d
Signatures:
Rectangle From
Rectangle From
Returns a rectangle at the specified point with a given width and height
Parameters:
Name | Type | Description |
---|---|---|
pt | Point 2d | The origin for the rectangle |
width | Double | Its width |
height | Double | Its height |
Return Type: Rectangle
Signatures:
Rectangle From
Returns a rectangle with pt1 and pt2 defining the two distant edge points.
Parameters:
Name | Type | Description |
---|---|---|
pt1 | Point 2d | The first point |
pt2 | Point 2d | The second point |
Return Type: Rectangle
Signatures:
Rectangle From
Returns a rectangle from a given x,y location with the specified width and height.
Parameters:
Name | Type | Description |
---|---|---|
x | Double | The x coordinate of the rectangle |
y | Double | The y coordinate of the rectangle |
width | Double | The width of the rectangle |
height | Double | The height of the rectangle |
Return Type: Rectangle
Usage:
Signatures:
Rectangle Left
The location of the left edge of the rectangle.
Parameters:
Name | Type | Description |
---|---|---|
rect | Rectangle | The rectangle. |
Return Type: Float
Signatures:
Rectangle Offset By
Returns a rectangle that is moved by the provided vector.
Parameters:
Name | Type | Description |
---|---|---|
rect | Rectangle | The original rectangle |
offset | Vector 2d | The amount and direction for the rectangle to move |
Return Type: Rectangle
Signatures:
Rectangle Right
The location of the right edge of the rectangle.
Parameters:
Name | Type | Description |
---|---|---|
rect | Rectangle | The rectangle. |
Return Type: Float
Signatures:
Rectangle To String
Get a text representation of the passed in rectangle.
Parameters:
Name | Type | Description |
---|---|---|
rect | Rectangle | The rectangle |
Return Type: String
Signatures:
Rectangle Top
The top of the rectangle.
Parameters:
Name | Type | Description |
---|---|---|
rect | Rectangle | The rectangle. |
Return Type: Float
Signatures:
Rectangles Intersect
Returns true if the two rectangles intersect.
Parameters:
Name | Type | Description |
---|---|---|
rect1 | Rectangle | The first rectangle |
rect2 | Rectangle | The second rectangle |
Return Type: Boolean
Signatures:
Triangle Barycenter
Return the barycenter of the triangle. This is one way of calculating the center point of a triangle.
Parameters:
Name | Type | Description |
---|---|---|
tri | Triangle | The triangle to get the center of |
Return Type: Point 2d
Signatures:
Triangle From
Triangle From
Generate a triangle from a set of points.
Parameters:
Name | Type | Description |
---|---|---|
p1 | Point 2d | The first point of the triangle |
p2 | Point 2d | The second point of the triangle |
p3 | Point 2d | The third point of the triangle |
Return Type: Triangle
Signatures:
Triangle From
Generate a triangle from a set of points.
Parameters:
Name | Type | Description |
---|---|---|
x1 | Double | The x coordinate for the first point |
y1 | Double | The y coordinate for the first point |
x2 | Double | The x coordinate for the second point |
y2 | Double | The y coordinate for the second point |
x3 | Double | The x coordinate for the third point |
y3 | Double | The y coordinate for the third point |
Return Type: Triangle
Signatures:
Triangle Rectangle Intersect
Returns true if the triangle intersects with the rectangle.
Parameters:
Name | Type | Description |
---|---|---|
tri | Triangle | The triangle to test |
rect | Rectangle | The rectangle to test |
Return Type: Boolean
Signatures:
Triangle To String
Returns a text description of the triangle.
Parameters:
Name | Type | Description |
---|---|---|
tri | Triangle | The triangle |
Return Type: String
Signatures:
Triangles Intersect
Returns true if the two triangles intersect.
Parameters:
Name | Type | Description |
---|---|---|
t1 | Triangle | The first triangle |
t2 | Triangle | The other triangle |
Return Type: Boolean
Signatures: