Table of Contents

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

A Vector3

The start point of the line segment.

B Vector3

The end point of the line segment.

P Vector3

The 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

dotProduct double

The dot product of the two vectors.

lengthA double

The magnitude (length) of the first vector.

lengthB double

The 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

dotProduct float

The dot product of the two vectors.

lengthA float

The magnitude (length) of the first vector.

lengthB float

The 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

fromX double

The X-coordinate of the starting position.

fromY double

The Y-coordinate of the starting position.

toX double

The X-coordinate of the target position.

toY double

The 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

from Vector2

The starting position vector.

to Vector2

The target position vector.

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

fromX float

The X-coordinate of the starting position.

fromY float

The Y-coordinate of the starting position.

toX float

The X-coordinate of the target position.

toY float

The 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

x1 double

The X-component of the first vector.

y1 double

The Y-component of the first vector.

z1 double

The Z-component of the first vector.

x2 double

The X-component of the second vector.

y2 double

The Y-component of the second vector.

z2 double

The 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

vector1 Vector3

The first vector.

vector2 Vector3

The second vector.

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

x1 float

The X-component of the first vector.

y1 float

The Y-component of the first vector.

z1 float

The Z-component of the first vector.

x2 float

The X-component of the second vector.

y2 float

The Y-component of the second vector.

z2 float

The 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

x1 double

The X-component of the first vector.

y1 double

The Y-component of the first vector.

x2 double

The X-component of the second vector.

y2 double

The 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

vector1 Vector2

The first vector.

vector2 Vector2

The second vector.

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

x1 float

The X-component of the first vector.

y1 float

The Y-component of the first vector.

x2 float

The X-component of the second vector.

y2 float

The 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

x1 double

The X-component of the first vector.

y1 double

The Y-component of the first vector.

z1 double

The Z-component of the first vector.

x2 double

The X-component of the second vector.

y2 double

The Y-component of the second vector.

z2 double

The 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

vector1 Vector3

The first vector.

vector2 Vector3

The second vector.

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

x1 float

The X-component of the first vector.

y1 float

The Y-component of the first vector.

z1 float

The Z-component of the first vector.

x2 float

The X-component of the second vector.

y2 float

The Y-component of the second vector.

z2 float

The 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

x double

The X-component of the vector.

y double

The Y-component of the vector.

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

vector Vector2

The 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

x float

The X-component of the vector.

y float

The Y-component of the vector.

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

x double

The X-component of the vector.

y double

The Y-component of the vector.

z double

The 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

vector Vector3

The 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

x float

The X-component of the vector.

y float

The Y-component of the vector.

z float

The 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

vector1 Vector2

The first point on the first line.

vector2 Vector2

The second point on the first line.

vector3 Vector2

The first point on the second line.

vector4 Vector2

The second point on the second line.

Returns

Vector2

A Vector2 representing the intersection point, or a vector of NaN values if the lines are parallel or coincident.