-
Notifications
You must be signed in to change notification settings - Fork 1
GameMath
Namespace: Verdant
public static class GameMath
A collection of helpful math functions.
Navigate
Property | Description |
---|---|
Random | The global Random instance, used by any internal random number generation. |
public static float AngleBetweenPoints(Vec2 a, Vec2 target)
Given two points in 2D space, get the angle between them.
Returns: A float representing the angle between the two points.
Parameter | Description |
---|---|
Vec2 a
|
The first point. |
Vec2 target
|
The second point. |
public static Vec2 Vec2FromAngle(float angle)
Given an angle, calculate an appropriate Vec2.
Returns: A Vec2 with a magnitude of 1, pointing in the direction of the angle.
Parameter | Description |
---|---|
float angle
|
The angle of the vector. |
public static float GetDistance(Vec2 a, Vec2 b)
Given two points in 2D space, get the distance between them.
Returns: The distance between the two points.
Parameter | Description |
---|---|
Vec2 a
|
The first point. |
Vec2 b
|
The second point. |
public static bool CheckRectIntersection(float x1, float y1, int w1, int h1, float x2, float y2, int w2, int h2)
Check if two AABBs are intersecting.
Returns: Returns true if the AABBs are intersecting, and false otherwise.
Parameter | Description |
---|---|
float x1
|
The x coordinate of the first AABB. |
float y1
|
The y coordinate of the first AABB. |
int w1
|
The width of the first AABB. |
int h1
|
The height of the first AABB. |
float x2
|
The x coordinate of the second AABB. |
float y2
|
The y coordinate of the second AABB. |
int w2
|
The width of the second AABB. |
int h2
|
The height of the second AABB. |
public static bool CheckRectIntersection(Vec2 pos1, int w1, int h1, Vec2 pos2, int w2, int h2)
Check if two AABBs are intersecting.
Returns: Returns true if the AABBs are intersecting, and false otherwise.
Parameter | Description |
---|---|
Vec2 pos1
|
The position of the first AABB. |
int w1
|
The width of the first AABB. |
int h1
|
The height of the first AABB. |
Vec2 pos2
|
The position of the second AABB. |
int w2
|
The width of the second AABB. |
int h2
|
The height of the second AABB. |
public static bool CheckPointOnRectIntersection(Vec2 point, float x, float y, float w, float h)
Check if a 2D point is intersecting with an AABB.
Returns: Returns true if the point is within the AABB, and false otherwise.
Parameter | Description |
---|---|
Vec2 point
|
The point. |
float x
|
The x coordinate of the AABB. |
float y
|
The y coordinate of the AABB. |
float w
|
The width of the AABB. |
float h
|
The height of the AABB. |
public static float RandomFloat()
Generate a random float value between 0 and 1.
Returns: A random float value.
public static float RandomFloat(float min, float max)
Generate a random float value within the given bounds.
Returns: A random float value.
Parameter | Description |
---|---|
float min
|
The minimum value of the float. |
float max
|
The maximum value of the float. |
public static int RandomInt(int min, int max)
Generate a random integer value within the given bounds.
Returns: A random integer value.
Parameter | Description |
---|---|
int min
|
The minimum value of the integer. |
int max
|
The maximum value of the integer. |
The Verdant wiki is automatically generated from documentation comments in the codebase by markify.