Class VectorExtensions
- Namespace
- Gamelogic.Extensions
- Assembly
- Assembly-CSharp.dll
Contains useful extension methods for vectors.
[Version(1, 0, 0)]
public static class VectorExtensions
- Inheritance
-
VectorExtensions
- Inherited Members
Methods
Dot(Vector2, Vector2)
Equivalent to Vector2.Dot(v1, v2).
public static float Dot(this Vector2 vector1, Vector2 vector2)
Parameters
Returns
- float
Vector2.
Dot(Vector3, Vector3)
Equivalent to Vector3.Dot(v1, v2).
public static float Dot(this Vector3 vector1, Vector3 vector2)
Parameters
Returns
- float
Vector3.
Dot(Vector4, Vector4)
Equivalent to Vector4.Dot(v1, v2).
public static float Dot(this Vector4 vector1, Vector4 vector2)
Parameters
Returns
- float
Vector4.
HadamardDiv(Vector2, Vector2)
Divides one vector component by another.
[Version(1, 4, 4)]
public static Vector2 HadamardDiv(this Vector2 thisVector, Vector2 otherVector)
Parameters
Returns
HadamardDiv(Vector3, Vector3)
Divides one vector component by another.
[Version(1, 4, 4)]
public static Vector3 HadamardDiv(this Vector3 thisVector, Vector3 otherVector)
Parameters
Returns
HadamardDiv(Vector4, Vector4)
Divides one vector component by another.
[Version(1, 4, 4)]
public static Vector4 HadamardDiv(this Vector4 thisVector, Vector4 otherVector)
Parameters
Returns
HadamardMod(Vector2, Vector2)
Multiplies component by component.
[Version(1, 4, 4)]
public static Vector2 HadamardMod(this Vector2 thisVector, Vector2 otherVector)
Parameters
Returns
HadamardMod(Vector3, Vector3)
Multiplies component by component.
[Version(2, 0, 0)]
public static Vector3 HadamardMod(this Vector3 thisVector, Vector3 otherVector)
Parameters
Returns
HadamardMod(Vector4, Vector4)
Multiplies component by component.
[Version(2, 0, 0)]
public static Vector4 HadamardMod(this Vector4 thisVector, Vector4 otherVector)
Parameters
Returns
HadamardMul(Vector2, Vector2)
Multiplies one vector componentwise by another.
[Version(1, 4, 4)]
public static Vector2 HadamardMul(this Vector2 thisVector, Vector2 otherVector)
Parameters
Returns
HadamardMul(Vector3, Vector3)
Multiplies one vector component by another.
[Version(1, 4, 4)]
public static Vector3 HadamardMul(this Vector3 thisVector, Vector3 otherVector)
Parameters
Returns
HadamardMul(Vector4, Vector4)
Multiplies one vector component by another.
[Version(1, 4, 4)]
public static Vector4 HadamardMul(this Vector4 thisVector, Vector4 otherVector)
Parameters
Returns
Perp(Vector2)
Returns the vector rotated 90 degrees counter-clockwise.
public static Vector2 Perp(this Vector2 vector)
Parameters
vector
Vector2
Returns
Remarks
The returned vector is always perpendicular to the given vector.
The perp dot product can be calculated using this: var perpDotProduct = Vector2.Dot(v1.Perp(), v2);
PerpDot(Vector2, Vector2)
Equivalent to Vector2.Dot(v1.Perp(), v2).
public static float PerpDot(this Vector2 vector1, Vector2 vector2)
Parameters
Returns
- float
Vector2.
PerpXY(Vector3)
Turns the vector 90 degrees anticlockwise as viewed from the front (keeping the z coordinate intact). Equivalent to
v.To2DXY().Perp().To3DXY(v.z);
public static Vector3 PerpXY(this Vector3 v)
Parameters
v
Vector3
Returns
PerpXZ(Vector3)
Turns the vector 90 degrees anticlockwise as viewed from the top (keeping the y coordinate intact). Equivalent to
v.To2DXZ().Perp().To3DXZ(v.y);
public static Vector3 PerpXZ(this Vector3 v)
Parameters
v
Vector3
Returns
Proj(Vector2, Vector2)
Returns the projection of this vector onto the given base.
public static Vector2 Proj(this Vector2 vector, Vector2 baseVector)
Parameters
Returns
Proj(Vector3, Vector3)
Returns the projection of this vector onto the given base.
public static Vector3 Proj(this Vector3 vector, Vector3 baseVector)
Parameters
Returns
Proj(Vector4, Vector4)
Returns the projection of this vector onto the given base.
public static Vector4 Proj(this Vector4 vector, Vector4 baseVector)
Parameters
Returns
ReflectAboutX(Vector2)
Reflects the vector about x-axis.
[Version(2, 1, 0)]
public static Vector2 ReflectAboutX(this Vector2 vector)
Parameters
vector
Vector2
Returns
ReflectAboutY(Vector2)
Reflects the vector about y-axis.
[Version(2, 1, 0)]
public static Vector2 ReflectAboutY(this Vector2 vector)
Parameters
vector
Vector2
Returns
Rej(Vector2, Vector2)
Returns the rejection of this vector onto the given base.
public static Vector2 Rej(this Vector2 vector, Vector2 baseVector)
Parameters
Returns
Remarks
<p>The sum of a vector's projection and rejection on a base is equal to
the original vector.
Rej(Vector3, Vector3)
Returns the rejection of this vector onto the given base.
public static Vector3 Rej(this Vector3 vector, Vector3 baseVector)
Parameters
Returns
Remarks
<p>The sum of a vector's projection and rejection on a base is equal to
the original vector.
Rej(Vector4, Vector4)
Returns the rejection of this vector onto the given base. The sum of a vector's projection and rejection on a base is equal to the original vector.
public static Vector4 Rej(this Vector4 vector, Vector4 baseVector)
Parameters
Returns
Rotate(Vector2, float)
Rotates a vector by a given angle.
public static Vector2 Rotate(this Vector2 vector, float angleInDeg)
Parameters
Returns
- Vector2
Rotated vector.
Rotate180(Vector2)
Rotates a vector by 180 degrees.
public static Vector2 Rotate180(this Vector2 vector)
Parameters
vector
Vector2
Returns
Rotate270(Vector2)
Rotates a vector by 270 degrees.
public static Vector2 Rotate270(this Vector2 vector)
Parameters
vector
Vector2
Returns
Rotate90(Vector2)
Rotates a vector by 90 degrees.
public static Vector2 Rotate90(this Vector2 vector)
Parameters
vector
Vector2
Returns
RotateAround(Vector2, float, Vector2)
Rotates a vector by a given angle around a given point.
public static Vector2 RotateAround(this Vector2 vector, float angleInDeg, Vector2 axisPosition)
Parameters
Returns
To2DXY(Vector3)
Converts a 3D vector to a 2D vector taking the x and y coordinates.
public static Vector2 To2DXY(this Vector3 vector)
Parameters
vector
Vector3
Returns
To2DXZ(Vector3)
Converts a 3D vector to a 2D vector taking the x and z coordinates.
public static Vector2 To2DXZ(this Vector3 vector)
Parameters
vector
Vector3
Returns
To2DYZ(Vector3)
Converts a 3D vector to a 2D vector taking the y and z coordinates.
public static Vector2 To2DYZ(this Vector3 vector)
Parameters
vector
Vector3
Returns
To3DXY(Vector2)
Converts a 2D vector to a 3D vector using the vector for the x and y coordinates, and 0 for the z coordinate.
public static Vector3 To3DXY(this Vector2 vector)
Parameters
vector
Vector2
Returns
To3DXY(Vector2, float)
Converts a 2D vector to a 3D vector using the vector for the x and y coordinates, and the given value for the z coordinate.
public static Vector3 To3DXY(this Vector2 vector, float z)
Parameters
Returns
To3DXZ(Vector2)
Converts a 2D vector to a 3D vector using the vector for the x and z coordinates, and 0 for the y coordinate.
public static Vector3 To3DXZ(this Vector2 vector)
Parameters
vector
Vector2
Returns
To3DXZ(Vector2, float)
Converts a 2D vector to a 3D vector using the vector for the x and z coordinates, and the given value for the y coordinate.
public static Vector3 To3DXZ(this Vector2 vector, float y)
Parameters
Returns
To3DYZ(Vector2)
Converts a 2D vector to a 3D vector using the vector for the y and z coordinates, and 0 for the x coordinate.
public static Vector3 To3DYZ(this Vector2 vector)
Parameters
vector
Vector2
Returns
To3DYZ(Vector2, float)
Converts a 2D vector to a 3D vector using the vector for the y and z coordinates, and the given value for the x coordinate.
public static Vector3 To3DYZ(this Vector2 vector, float x)
Parameters
Returns
WithIncX(Vector2, float)
Returns a copy of the vector with the x-coordinate incremented with the given value.
public static Vector2 WithIncX(this Vector2 vector, float xInc)
Parameters
Returns
WithIncX(Vector3, float)
Returns a copy of the vector with the x-coordinate incremented with the given value.
public static Vector3 WithIncX(this Vector3 vector, float xInc)
Parameters
Returns
WithIncY(Vector2, float)
Returns a copy of the vector with the y-coordinate incremented with the given value.
public static Vector2 WithIncY(this Vector2 vector, float yInc)
Parameters
Returns
WithIncY(Vector3, float)
Returns a copy of the vector with the y-coordinate incremented with the given value.
public static Vector3 WithIncY(this Vector3 vector, float yInc)
Parameters
Returns
WithIncZ(Vector3, float)
Returns a copy of the vector with the z-coordinate incremented with the given value.
public static Vector3 WithIncZ(this Vector3 vector, float zInc)
Parameters
Returns
WithX(Vector2, float)
Returns a copy of this vector with the given x-coordinate.
[Version(2, 0, 0)]
public static Vector2 WithX(this Vector2 vector, float x)
Parameters
Returns
WithX(Vector3, float)
Returns a copy of this vector with the given x-coordinate.
[Version(2, 0, 0)]
public static Vector3 WithX(this Vector3 vector, float x)
Parameters
Returns
WithY(Vector2, float)
Returns a copy of this vector with the given y-coordinate.
[Version(2, 0, 0)]
public static Vector2 WithY(this Vector2 vector, float y)
Parameters
Returns
WithY(Vector3, float)
Returns a copy of this vector with the given y-coordinate.
[Version(2, 0, 0)]
public static Vector3 WithY(this Vector3 vector, float y)
Parameters
Returns
WithZ(Vector3, float)
Returns a copy of this vector with the given z-coordinate.
[Version(2, 0, 0)]
public static Vector3 WithZ(this Vector3 vector, float z)
Parameters
Returns
XZY(Vector3)
Creates a new vector by permuting the given vector's coordinates in the order XZY.
public static Vector3 XZY(this Vector3 vector)
Parameters
vector
Vector3
Returns
YX(Vector2)
Swaps the x and y coordinates of the vector.
public static Vector2 YX(this Vector2 vector)
Parameters
vector
Vector2
Returns
YXZ(Vector3)
Creates a new vector by permuting the given vector's coordinates in the order YXZ.
[Version(1, 4, 3)]
public static Vector3 YXZ(this Vector3 vector)
Parameters
vector
Vector3
Returns
YZX(Vector3)
Creates a new vector by permuting the given vector's coordinates in the order YZX.
public static Vector3 YZX(this Vector3 vector)
Parameters
vector
Vector3
Returns
ZXY(Vector3)
Creates a new vector by permuting the given vector's coordinates in the order ZXY.
public static Vector3 ZXY(this Vector3 vector)
Parameters
vector
Vector3
Returns
ZYX(Vector3)
Creates a new vector by permuting the given vector's coordinates in the order ZYX.
[Version(1, 4, 3)]
public static Vector3 ZYX(this Vector3 vector)
Parameters
vector
Vector3