Physics
Functions
Bitmap Circle Collision
Bitmap Circle Collision
Tests if a bitmap drawn at pt
would intersect with a circle.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to test |
pt | Point 2d | The location where the bitmap is drawn |
circ | Circle | The circle to test |
Return Type: Boolean
Signatures:
Bitmap Circle Collision
Tests if a bitmap drawn at x
, y
would intersect with a circle.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to test |
x | Double | The x location where the bitmap is drawn |
y | Double | The y location where the bitmap is drawn |
circ | Circle | The circle to test |
Return Type: Boolean
Signatures:
Bitmap Circle Collision
Tests if a bitmap cell drawn using a passed in translation, will intersect with a circle. You can use this to detect collisions between bitmaps and circles.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to test |
cell | Integer | The cell of the bitmap to check |
translation | Matrix 2d | The matrix used to transfrom the bitmap when drawing |
circ | Circle | The circle to test |
Return Type: Boolean
Signatures:
Bitmap Circle Collision
Tests if a bitmap cell drawn at pt
would intersect with a circle.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to test |
cell | Integer | The cell of the bitmap to check |
pt | Point 2d | The location where the bitmap is drawn |
circ | Circle | The circle to test |
Return Type: Boolean
Signatures:
Bitmap Circle Collision
Tests if a bitmap cell drawn at x
, y
would intersect with a circle.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to test |
cell | Integer | The cell of the bitmap to check |
x | Double | The x location where the bitmap is drawn |
y | Double | The y location where the bitmap is drawn |
circ | Circle | The circle to test |
Return Type: Boolean
Signatures:
Bitmap Collision
Bitmap Collision
Check if two bitmaps collide.
Parameters:
Name | Type | Description |
---|---|---|
bmp1 | Bitmap | The first bitmap |
x1 | Double | The x location where the first bitmap is drawn |
y1 | Double | The y location where the first bitmap is drawn |
bmp2 | Bitmap | The second bitmap |
x2 | Double | The x location where the second bitmap is drawn |
y2 | Double | The y location where the second bitmap is drawn |
Return Type: Boolean
Signatures:
Bitmap Collision
Check if two bitmaps collide.
Parameters:
Name | Type | Description |
---|---|---|
bmp1 | Bitmap | The first bitmap |
pt1 | Point 2d | The point where bitmap 1 is drawn |
bmp2 | Bitmap | The second bitmap |
pt2 | Point 2d | The point where bitmap 2 is drawn |
Return Type: Boolean
Signatures:
Bitmap Collision
Check if two bitmaps collide, based on their cell and transform matricies.
Parameters:
Name | Type | Description |
---|---|---|
bmp1 | Bitmap | The first bitmap |
cell1 | Integer | The cell of the first bitmap. |
matrix1 | Matrix 2d | The transformation for the first matrix |
bmp2 | Bitmap | The second bitmap |
cell2 | Integer | The cell of the second bitmap. |
matrix2 | Matrix 2d | The transformation for the second matrix |
Return Type: Boolean
Signatures:
Bitmap Collision
Check if two bitmaps collide.
Parameters:
Name | Type | Description |
---|---|---|
bmp1 | Bitmap | The first bitmap |
cell1 | Integer | The cell of the first bitmap. |
pt1 | Point 2d | The point where bitmap 1 is drawn |
bmp2 | Bitmap | The second bitmap |
cell2 | Integer | The cell of the second bitmap. |
pt2 | Point 2d | The point where bitmap 2 is drawn |
Return Type: Boolean
Signatures:
Bitmap Collision
Check if two bitmaps collide.
Parameters:
Name | Type | Description |
---|---|---|
bmp1 | Bitmap | The first bitmap |
cell1 | Integer | The cell of the first bitmap. |
x1 | Double | The x location where the first bitmap is drawn |
y1 | Double | The y location where the first bitmap is drawn |
bmp2 | Bitmap | The second bitmap |
cell2 | Integer | The cell of the second bitmap. |
x2 | Double | The x location where the second bitmap is drawn |
y2 | Double | The y location where the second bitmap is drawn |
Return Type: Boolean
Signatures:
Bitmap Point Collision
Bitmap Point Collision
Tests if a bitmap drawn using the passed in translation matrix would draw a pixel at the passed in point. Use to check collisions between a point and a bitmap.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to test. |
translation | Matrix 2d | The translation matrix that represents the position, scale, and rotation of the bitmap when it is drawn. |
pt | Point 2d | The point in the resulting drawing that is being tested. |
Return Type: Boolean
Signatures:
Bitmap Point Collision
Tests if a bitmap drawn at the bmp_pt
point would draw a pixel at point pt
. Use to check collisions between a point and a bitmap.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to test. |
bmp_pt | Point 2d | The point where the bitmap is drawn. |
pt | Point 2d | The point in the resulting drawing that is being tested. |
Return Type: Boolean
Signatures:
Bitmap Point Collision
Tests if a bitmap drawn at x,y would draw a pixel at the passed in point. Use to check collisions between a point and a bitmap.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to test. |
bmp_x | Double | The x location where the bitmap is drawn |
bmp_y | Double | The y location where the bitmap is drawn |
x | Double | The x location of the point to test |
y | Double | The y location of the point to test |
Return Type: Boolean
Signatures:
Bitmap Point Collision
Tests if a bitmap cell drawn using the passed in translation matrix would draw a pixel at the passed in point.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to test. |
cell | Integer | The cell of the bitmap to check. |
translation | Matrix 2d | The translation matrix that represents the position, scale, and rotation of the bitmap when it is drawn. |
pt | Point 2d | The point in the resulting drawing that is being tested. |
Return Type: Boolean
Signatures:
Bitmap Point Collision
Tests if a cell of a bitmap drawn at x,y would draw a pixel at the passed in point. Use to check collisions between a point and a bitmap.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to test |
cell | Integer | The cell of the bitmap to test |
bmp_pt | Point 2d | The point where the bitmap is drawn. |
pt | Point 2d | The point in the resulting drawing that is being tested. |
Return Type: Boolean
Signatures:
Bitmap Point Collision
Tests if a cell of a bitmap drawn at x,y would draw a pixel at the passed in point. Use to check collisions between a point and a bitmap.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to test |
cell | Integer | The cell of the bitmap to test |
bmp_x | Double | The x location where the bitmap is drawn |
bmp_y | Double | The y location where the bitmap is drawn |
x | Double | The x location of the point to test |
y | Double | The y location of the point to test |
Return Type: Boolean
Signatures:
Bitmap Rectangle Collision
Bitmap Rectangle Collision
Tests if a bitmap drawn at pt
would intersect with a rectangle.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to test |
pt | Point 2d | The location where the bitmap is drawn |
rect | Rectangle | The rectangle to test |
Return Type: Boolean
Signatures:
Bitmap Rectangle Collision
Tests if a bitmap drawn at x
, y
would intersect with a rectangle.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to test |
x | Double | The x location where the bitmap is drawn |
y | Double | The y location where the bitmap is drawn |
rect | Rectangle | The rectangle to test |
Return Type: Boolean
Signatures:
Bitmap Rectangle Collision
Tests if a bitmap cell drawn using a passed in translation, will intersect with a rectangle. You can use this to detect collisions between bitmaps and rectangles.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to test |
cell | Integer | The cell of the bitmap to check |
translation | Matrix 2d | The matrix used to transfrom the bitmap when drawing |
rect | Rectangle | The rectangle to test |
Return Type: Boolean
Signatures:
Bitmap Rectangle Collision
Tests if a bitmap cell drawn at pt
would intersect with a rectangle.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to test |
cell | Integer | The cell of the bitmap to check |
pt | Point 2d | The location where the bitmap is drawn |
rect | Rectangle | The rectangle to test |
Return Type: Boolean
Signatures:
Bitmap Rectangle Collision
Tests if a cell of the bitmap drawn at x
, y
would intersect with a rectangle.
Parameters:
Name | Type | Description |
---|---|---|
bmp | Bitmap | The bitmap to test |
cell | Integer | The cell of the bitmap to check |
x | Double | The x location where the bitmap is drawn |
y | Double | The y location where the bitmap is drawn |
rect | Rectangle | The rectangle to test |
Return Type: Boolean
Signatures:
Sprite Bitmap Collision
Sprite Bitmap Collision
Tests if a sprite will collide with a bitmap drawn at the indicated location.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to test |
bmp | Bitmap | The bitmap to test |
x | Double | The x location where the bitmap is drawn |
y | Double | The y location where the bitmap is drawn |
Return Type: Boolean
Signatures:
Sprite Bitmap Collision
Tests if a sprite will collide with a bitmap drawn at the indicated location.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to test |
bmp | Bitmap | The bitmap to test |
cell | Integer | The cell of the bitmap to check |
pt | Point 2d | The point where the bitmap is drawn |
Return Type: Boolean
Signatures:
Sprite Bitmap Collision
Tests if a sprite will collide with a bitmap drawn at the indicated location.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to test |
bmp | Bitmap | The bitmap to test |
cell | Integer | The cell of the bitmap to check |
x | Double | The x location where the bitmap is drawn |
y | Double | The y location where the bitmap is drawn |
Return Type: Boolean
Signatures:
Sprite Collision
Tests if two given sprites s1
and s2
are collided
Parameters:
Name | Type | Description |
---|---|---|
s1 | Sprite | the first Sprite to test |
s2 | Sprite | the second Sprite to test |
Return Type: Boolean
Signatures:
Sprite Point Collision
Tests if a sprite is drawn at a given point.
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to test |
pt | Point 2d | The point to check |
Return Type: Boolean
Signatures:
Sprite Rectangle Collision
Tests if a sprite is drawn within an given area (rectangle).
Parameters:
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to test |
rect | Rectangle | The rectangle to check |
Return Type: Boolean
Signatures:
Apply Matrix
Apply Matrix
Use a matrix to transform all of the points in a quad.
Parameters:
Name | Type | Description |
---|---|---|
matrix | Matrix 2d | The matrix with the transformations needed. |
q | Quad | The quad to transform. |
Signatures:
Apply Matrix
Use a matrix to transform all of the points in a triangle.
Parameters:
Name | Type | Description |
---|---|---|
m | Matrix 2d | The matrix to be applied to the triangle. |
tri | Triangle | The triangle to tranform. |
Signatures:
Identity Matrix
Returns the identity matrix. When a matrix_2d or Vector is multiplied by the identity matrix the result is the original matrix or vector.
Return Type: Matrix 2d
Signatures:
Matrix Inverse
Calculate the inverse of a matrix.
Parameters:
Name | Type | Description |
---|---|---|
m | Matrix 2d | The matrix to invert. |
Return Type: Matrix 2d
Signatures:
Matrix Multiply
Matrix Multiply
Multiplies the Point 2d
parameter v with the [
Matrix 2d](/api/physics/#matrix-2d)
m and returns the result as a Point 2d
. Use this to transform the vector with the matrix (to apply scaling, rotation or translation effects).
Parameters:
Name | Type | Description |
---|---|---|
m | Matrix 2d | The matrix with the transformation to apply. |
pt | Point 2d | The point to be transformed. |
Return Type: Point 2d
Signatures:
Matrix Multiply
Multiplies the two Matrix 2d
parameters, m1
by m2
, and returns the result as a new Matrix 2d
. Use this to combine the effects to two matrix transformations.
Parameters:
Name | Type | Description |
---|---|---|
m1 | Matrix 2d | The first matrix |
m2 | Matrix 2d | The second matrix |
Return Type: Matrix 2d
Signatures:
Matrix Multiply
Multiplies the Vector
parameter v
with the Matrix 2d
m
and returns the result as a Vector
. Use this to transform the vector with the matrix (to apply scaling, rotation or translation effects).
Parameters:
Name | Type | Description |
---|---|---|
m | Matrix 2d | The matrix with the transformation to apply. |
v | Vector 2d | The vector to be transformed. |
Return Type: Vector 2d
Signatures:
Matrix To String
This function returns a string representation of a Matrix.
Parameters:
Name | Type | Description |
---|---|---|
matrix | Matrix 2d | The matrix to convert to a string. |
Return Type: String
Signatures:
Rotation Matrix
Returns a rotation matrix that rotates 2d points by the angle.
Parameters:
Name | Type | Description |
---|---|---|
deg | Double | The amount to rotate points |
Return Type: Matrix 2d
Signatures:
Scale Matrix
Scale Matrix
Create a scale matrix that scales x and y to different degrees.
Parameters:
Name | Type | Description |
---|---|---|
scale | Point 2d | The amount to scale, with separate x and y components. |
Return Type: Matrix 2d
Signatures:
Scale Matrix
Create a scale matrix that scales x and y to different degrees.
Parameters:
Name | Type | Description |
---|---|---|
scale | Vector 2d | The amount to scale, with separate x and y components. |
Return Type: Matrix 2d
Signatures:
Scale Matrix
Returns a matrix that can be used to scale 2d points (both x and y).
Parameters:
Name | Type | Description |
---|---|---|
scale | Double | The amount to scale points by. |
Return Type: Matrix 2d
Signatures:
Scale Rotate Translate Matrix
Create a matrix that can scale, rotate then translate geometry points.
Parameters:
Name | Type | Description |
---|---|---|
scale | Point 2d | The amount to scale |
deg | Double | The amount to rotate |
translate | Point 2d | The amount to move |
Return Type: Matrix 2d
Signatures:
Translation Matrix
Translation Matrix
Returns a translation matric used to translate 2d points by the distance in the point_2d.
Parameters:
Name | Type | Description |
---|---|---|
pt | Point 2d | The point to translate to. |
Return Type: Matrix 2d
Signatures:
Translation Matrix
Returns a translation matric used to translate 2d points by the distance in the vector_2d.
Parameters:
Name | Type | Description |
---|---|---|
pt | Vector 2d | The point to translate to. |
Return Type: Matrix 2d
Signatures:
Translation Matrix
Returns a matrix that can be used to translate 2d points. Moving them by dx and dy.
Parameters:
Name | Type | Description |
---|---|---|
dx | Double | The amount to move points along the x axis. |
dy | Double | The amount to move points along the y axis. |
Return Type: Matrix 2d
Signatures:
Angle Between
Calculates the angle from one vector to another.
Parameters:
Name | Type | Description |
---|---|---|
v1 | Vector 2d | The first vector |
v2 | Vector 2d | The second vector |
Return Type: Double
Signatures:
Dot Product
Calculates the dot product (scalar product) between the two vector parameters provided (v1
and v2
). It returns the result as a scalar value. If the result is 0.0 it means that the vectors are orthogonal (at right angles to each other). If v1
and v2
are unit vectors (length of 1.0) and the dot product is 1.0, it means that v1
and v2
vectors are parallel.
Parameters:
Name | Type | Description |
---|---|---|
v1 | Vector 2d | The first vector |
v2 | Vector 2d | The other vector |
Return Type: Double
Signatures:
Is Zero Vector
Returns if the vector is a null/zero vector — having no size or direction.
Parameters:
Name | Type | Description |
---|---|---|
v | Vector 2d | The vector |
Return Type: Boolean
Signatures:
Ray Intersection Point
Casts a ray in a heading and returns true is it intersects with a line
Parameters:
Name | Type | Description |
---|---|---|
from_pt | Point 2d | The origin of the ray |
heading | Vector 2d | The direction the ray is heading (as a Vector 2d ) |
l | Line | The line to be checked |
pt | Point 2d | Outputs the point where the line and ray intersect |
Return Type: Boolean
Signatures:
Unit Vector
Returns the unit vector of the parameter vector (v). The unit vector has a magnitude of 1, resulting in a vector that indicates the direction of the original vector.
Parameters:
Name | Type | Description |
---|---|---|
v | Vector 2d | The vector |
Return Type: Vector 2d
Signatures:
Vector Add
Adds the two passed in vectors returns the result as new Vector 2d
.
Parameters:
Name | Type | Description |
---|---|---|
v1 | Vector 2d | The first vector. |
v2 | Vector 2d | The other vector. |
Return Type: Vector 2d
Signatures:
Vector Angle
Calculates the angle of a vector
Parameters:
Name | Type | Description |
---|---|---|
v | Vector 2d | The vector |
Return Type: Double
Signatures:
Vector From Angle
Returns a Vector 2d
from the supplied angle and distance.
Parameters:
Name | Type | Description |
---|---|---|
angle | Double | The angle in degrees |
magnitude | Double | The length of the vector |
Return Type: Vector 2d
Signatures:
Vector From Line
Returns a vector that points from the start to the end of a line.
Parameters:
Name | Type | Description |
---|---|---|
l | Line | The line |
Return Type: Vector 2d
Signatures:
Vector From Point To Rect
Returns a vector from a point to a rectangle.
Parameters:
Name | Type | Description |
---|---|---|
pt | Point 2d | The point |
rect | Rectangle | The rectangle |
Return Type: Vector 2d
Signatures:
Vector In Rect
Returns true if the resulting vector would end in the rectangle if placed at the origin.
Parameters:
Name | Type | Description |
---|---|---|
v | Vector 2d | The vector |
rect | Rectangle | The rectangle |
Return Type: Boolean
Signatures:
Vector Invert
Returns a new Vector that is an inverted version of the parameter vector (v). In other words, the -/+ sign of the x and y values are changed.
Parameters:
Name | Type | Description |
---|---|---|
v | Vector 2d | The vector |
Return Type: Vector 2d
Signatures:
Vector Limit
Returns a scaled vector that ensures the new vector points in the same direction as v, but has a magnitude that is limited to the length specified in the limit prameter.
Parameters:
Name | Type | Description |
---|---|---|
v | Vector 2d | The vector |
limit | Double | Its maximum magnitude |
Return Type: Vector 2d
Signatures:
Vector Magnitude
Returns the magnitude (or “length”) of the vector.
Parameters:
Name | Type | Description |
---|---|---|
v | Vector 2d | The vector |
Return Type: Double
Signatures:
Vector Magnitude Squared
Returns the squared magnitude (or “length”) of the vector.
Parameters:
Name | Type | Description |
---|---|---|
v | Vector 2d | The vector |
Return Type: Double
Signatures:
Vector Multiply
Multiplies the vector by the passed in value.
Parameters:
Name | Type | Description |
---|---|---|
v1 | Vector 2d | The original vector |
s | Double | The amount to multiply by |
Return Type: Vector 2d
Signatures:
Vector Normal
Returns a new Vector 2d
that is perpendicular (“normal”) to the parameter vector v
provided. The concept of a “normal” vector is usually extracted from (or associated with) a line. Note: when passed a zero or null vector (a vector with no magnitude or direction) then this function returns a zero/null vector.
Parameters:
Name | Type | Description |
---|---|---|
v | Vector 2d | The vector |
Return Type: Vector 2d
Signatures:
Vector Out Of Circle From Circle
Returns a vector to back one circle out of another, assuming the first circle was moving at a specified velocity.
Parameters:
Name | Type | Description |
---|---|---|
src | Circle | The circle that is moving |
bounds | Circle | The area you want to move the circle out of |
velocity | Vector 2d | The circle’s velocity |
Return Type: Vector 2d
Signatures:
Vector Out Of Circle From Point
Returns the vector out to move a point back out of a circle, given the point was moving at the specified velocity.
Parameters:
Name | Type | Description |
---|---|---|
pt | Point 2d | The point that is moving |
c | Circle | The circle you want to move the point out of |
velocity | Vector 2d | The point’s velocity |
Return Type: Vector 2d
Signatures:
Vector Out Of Rect From Circle
Returns a vector that can be used to move a circle back out of a rectangle, given that the circle is moving at the specified velocity.
Parameters:
Name | Type | Description |
---|---|---|
c | Circle | The circle that is moving |
rect | Rectangle | The area you wan to move the circle out of |
velocity | Vector 2d | The circle’s velocity |
Return Type: Vector 2d
Signatures:
Vector Out Of Rect From Point
Determines the vector needed to move back from point pt
out of rectangle rect
given the point was moving at the velocity specified.
Parameters:
Name | Type | Description |
---|---|---|
pt | Point 2d | The point you want to move out of a rectangle |
rect | Rectangle | The rectangle to move out of |
velocity | Vector 2d | The velocity of the point. This is used to determine where the point should return to. |
Return Type: Vector 2d
Signatures:
Vector Out Of Rect From Rect
Returns the vector needed to move rectangle src
back out of rectangle bounds
assuming the rectangle was moving at the velocity specified.
Parameters:
Name | Type | Description |
---|---|---|
src | Rectangle | The rectangle you want to move. |
bounds | Rectangle | The area you want to move the rectangle out of |
velocity | Vector 2d | The velocity of the src rectangle |
Return Type: Vector 2d
Signatures:
Vector Point To Point
Returns a Vector 2d
created from the difference from the p1
to the second p2
points (Point2D
).
Parameters:
Name | Type | Description |
---|---|---|
start | Point 2d | The starting point |
end_pt | Point 2d | The ending point |
Return Type: Vector 2d
Signatures:
Vector Subtract
Subtracts the second vector parameter (v2
) from the first vector (v1
) and returns the result as new Vector 2d
.
Parameters:
Name | Type | Description |
---|---|---|
v1 | Vector 2d | The first vector. |
v2 | Vector 2d | The other vector. |
Return Type: Vector 2d
Signatures:
Vector To
Vector To
Returns a new Vector 2d
using the x and y value of a Point 2d
parameter. This is a vector from the origin to that point.
Parameters:
Name | Type | Description |
---|---|---|
p1 | Point 2d | The point |
Return Type: Vector 2d
Signatures:
Vector To
Returns a vector to the indicated point.
Parameters:
Name | Type | Description |
---|---|---|
x | Double | The amount to move horizontally |
y | Double | The amount to move vertically |
Return Type: Vector 2d
Signatures:
Vector To String
Get a text description of the Vector 2d
.
Parameters:
Name | Type | Description |
---|---|---|
v | Vector 2d | The vector |
Return Type: String
Signatures:
Vectors Equal
Determines if two vectors are the same.
Parameters:
Name | Type | Description |
---|---|---|
v1 | Vector 2d | The first vector |
v2 | Vector 2d | The other vector |
Return Type: Boolean
Signatures:
Vectors Not Equal
Determines if two vectors are not the same.
Parameters:
Name | Type | Description |
---|---|---|
v1 | Vector 2d | The first vector |
v2 | Vector 2d | The other vector |
Return Type: Boolean
Signatures:
Types
Matrix 2d
Field | Type | Description |
---|---|---|
elements | Double | The elements of the matrix |
In SplashKit, matrices can be used to combine together a number of
operations that need to be performed on Vector 2d
values. You can
translate, rotate and scale, and combine these together into a
single matrix that can then be applied to vectors and points.