Class VectorGm
- Namespace
- Gamem
- Assembly
- Gamem.dll
Provides static methods for vector mathematics in 2D and 3D spaces.
public static class VectorGm
- Inheritance
-
VectorGm
- Inherited Members
Methods
ClosestPointOnLine(Vector3, Vector3, Vector3)
Finds the closest point on a 3D line segment AB to a given point P, clamping the result to the segment bounds.
public static Vector3 ClosestPointOnLine(Vector3 A, Vector3 B, Vector3 P)
Parameters
AVector3The start point of the line segment.
BVector3The end point of the line segment.
PVector3The target point in 3D space.
Returns
- Vector3
The position on the segment AB that is nearest to point P.
GetAngleBetween(double, double, double)
Calculates the angle between two vectors in radians using their dot product and magnitudes.
public static double GetAngleBetween(double dotProduct, double lengthA, double lengthB)
Parameters
dotProductdoubleThe dot product of the two vectors.
lengthAdoubleThe magnitude (length) of the first vector.
lengthBdoubleThe magnitude (length) of the second vector.
Returns
- double
The angle between the vectors in radians.
GetAngleBetween(float, float, float)
Calculates the angle between two vectors in radians using their dot product and magnitudes.
public static float GetAngleBetween(float dotProduct, float lengthA, float lengthB)
Parameters
dotProductfloatThe dot product of the two vectors.
lengthAfloatThe magnitude (length) of the first vector.
lengthBfloatThe magnitude (length) of the second vector.
Returns
- float
The angle between the vectors in radians.
GetAngleToTarget(double, double, double, double)
Calculates the angle in radians from a starting point to a target point in 2D space.
public static double GetAngleToTarget(double fromX, double fromY, double toX, double toY)
Parameters
fromXdoubleThe X-coordinate of the starting position.
fromYdoubleThe Y-coordinate of the starting position.
toXdoubleThe X-coordinate of the target position.
toYdoubleThe Y-coordinate of the target position.
Returns
- double
The angle in radians in the range (-π, π].
GetAngleToTarget(Vector2, Vector2)
Calculates the angle in radians from a starting vector to a target vector in 2D space.
public static float GetAngleToTarget(Vector2 from, Vector2 to)
Parameters
Returns
- float
The angle in radians in the range (-π, π].
GetAngleToTarget(float, float, float, float)
Calculates the angle in radians from a starting point to a target point in 2D space.
public static float GetAngleToTarget(float fromX, float fromY, float toX, float toY)
Parameters
fromXfloatThe X-coordinate of the starting position.
fromYfloatThe Y-coordinate of the starting position.
toXfloatThe X-coordinate of the target position.
toYfloatThe Y-coordinate of the target position.
Returns
- float
The angle in radians in the range (-π, π].
GetCrossProduct(double, double, double, double, double, double)
Calculates the cross product of two 3D vectors.
public static (double x, double y, double z) GetCrossProduct(double x1, double y1, double z1, double x2, double y2, double z2)
Parameters
x1doubleThe X-component of the first vector.
y1doubleThe Y-component of the first vector.
z1doubleThe Z-component of the first vector.
x2doubleThe X-component of the second vector.
y2doubleThe Y-component of the second vector.
z2doubleThe Z-component of the second vector.
Returns
- (double x, double y, double z)
A tuple representing the resulting 3D vector perpendicular to both input vectors
GetCrossProduct(Vector3, Vector3)
Calculates the cross product of two 3D vectors.
public static Vector3 GetCrossProduct(Vector3 vector1, Vector3 vector2)
Parameters
Returns
- Vector3
A vector representing the resulting 3D vector perpendicular to both input vectors
GetCrossProduct(float, float, float, float, float, float)
Calculates the cross product of two 3D vectors.
public static (float x, float y, float z) GetCrossProduct(float x1, float y1, float z1, float x2, float y2, float z2)
Parameters
x1floatThe X-component of the first vector.
y1floatThe Y-component of the first vector.
z1floatThe Z-component of the first vector.
x2floatThe X-component of the second vector.
y2floatThe Y-component of the second vector.
z2floatThe Z-component of the second vector.
Returns
- (float x, float y, float z)
A tuple representing the resulting 3D vector perpendicular to both input vectors
GetDotProduct(double, double, double, double)
Calculates the dot product of two 2D vectors.
public static double GetDotProduct(double x1, double y1, double x2, double y2)
Parameters
x1doubleThe X-component of the first vector.
y1doubleThe Y-component of the first vector.
x2doubleThe X-component of the second vector.
y2doubleThe Y-component of the second vector.
Returns
- double
The scalar dot product of the two 2D vectors.
GetDotProduct(Vector2, Vector2)
Calculates the dot product of two 2D vectors.
public static float GetDotProduct(Vector2 vector1, Vector2 vector2)
Parameters
Returns
- float
The scalar dot product of the two 2D vectors.
GetDotProduct(float, float, float, float)
Calculates the dot product of two 2D vectors.
public static float GetDotProduct(float x1, float y1, float x2, float y2)
Parameters
x1floatThe X-component of the first vector.
y1floatThe Y-component of the first vector.
x2floatThe X-component of the second vector.
y2floatThe Y-component of the second vector.
Returns
- float
The scalar dot product of the two 2D vectors.
GetDotProduct3D(double, double, double, double, double, double)
Calculates the dot product of two 3D vectors.
public static double GetDotProduct3D(double x1, double y1, double z1, double x2, double y2, double z2)
Parameters
x1doubleThe X-component of the first vector.
y1doubleThe Y-component of the first vector.
z1doubleThe Z-component of the first vector.
x2doubleThe X-component of the second vector.
y2doubleThe Y-component of the second vector.
z2doubleThe Z-component of the second vector.
Returns
- double
The scalar dot product of the two 3D vectors.
GetDotProduct3D(Vector3, Vector3)
Calculates the dot product of two 3D vectors.
public static float GetDotProduct3D(Vector3 vector1, Vector3 vector2)
Parameters
Returns
- float
The scalar dot product of the two 3D vectors.
GetDotProduct3D(float, float, float, float, float, float)
Calculates the dot product of two 3D vectors.
public static float GetDotProduct3D(float x1, float y1, float z1, float x2, float y2, float z2)
Parameters
x1floatThe X-component of the first vector.
y1floatThe Y-component of the first vector.
z1floatThe Z-component of the first vector.
x2floatThe X-component of the second vector.
y2floatThe Y-component of the second vector.
z2floatThe Z-component of the second vector.
Returns
- float
The scalar dot product of the two 3D vectors.
GetMagnitude(double, double)
Calculates the magnitude (length) of a 2D vector.
public static double GetMagnitude(double x, double y)
Parameters
Returns
- double
The magnitude of the 2D vector.
GetMagnitude(Vector2)
Calculates the magnitude (length) of a 2D vector.
public static float GetMagnitude(Vector2 vector)
Parameters
vectorVector2The vector.
Returns
- float
The magnitude of the 2D vector.
GetMagnitude(float, float)
Calculates the magnitude (length) of a 2D vector.
public static float GetMagnitude(float x, float y)
Parameters
Returns
- float
The magnitude of the 2D vector.
GetMagnitude3D(double, double, double)
Calculates the magnitude (length) of a 3D vector.
public static double GetMagnitude3D(double x, double y, double z)
Parameters
xdoubleThe X-component of the vector.
ydoubleThe Y-component of the vector.
zdoubleThe Z-component of the vector.
Returns
- double
The magnitude of the 3D vector.
GetMagnitude3D(Vector3)
Calculates the magnitude (length) of a 3D vector.
public static float GetMagnitude3D(Vector3 vector)
Parameters
vectorVector3The vector.
Returns
- float
The magnitude of the 3D vector.
GetMagnitude3D(float, float, float)
Calculates the magnitude (length) of a 3D vector.
public static float GetMagnitude3D(float x, float y, float z)
Parameters
xfloatThe X-component of the vector.
yfloatThe Y-component of the vector.
zfloatThe Z-component of the vector.
Returns
- float
The magnitude of the 3D vector.
LineIntersection(Vector2, Vector2, Vector2, Vector2)
Calculates the 2D intersection point of two infinitely long lines.
public static Vector2 LineIntersection(Vector2 vector1, Vector2 vector2, Vector2 vector3, Vector2 vector4)
Parameters
vector1Vector2The first point on the first line.
vector2Vector2The second point on the first line.
vector3Vector2The first point on the second line.
vector4Vector2The second point on the second line.