Table of Contents

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

vector1 Vector2

The first operand.

vector2 Vector2

The second operand.

Returns

float

Vector2.

Dot(Vector3, Vector3)

Equivalent to Vector3.Dot(v1, v2).

public static float Dot(this Vector3 vector1, Vector3 vector2)

Parameters

vector1 Vector3

The first operand.

vector2 Vector3

The second operand.

Returns

float

Vector3.

Dot(Vector4, Vector4)

Equivalent to Vector4.Dot(v1, v2).

public static float Dot(this Vector4 vector1, Vector4 vector2)

Parameters

vector1 Vector4

The first operand.

vector2 Vector4

The second operand.

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

thisVector Vector2
otherVector Vector2

Returns

Vector2

HadamardDiv(Vector3, Vector3)

Divides one vector component by another.

[Version(1, 4, 4)]
public static Vector3 HadamardDiv(this Vector3 thisVector, Vector3 otherVector)

Parameters

thisVector Vector3
otherVector Vector3

Returns

Vector3

HadamardDiv(Vector4, Vector4)

Divides one vector component by another.

[Version(1, 4, 4)]
public static Vector4 HadamardDiv(this Vector4 thisVector, Vector4 otherVector)

Parameters

thisVector Vector4
otherVector Vector4

Returns

Vector4

HadamardMod(Vector2, Vector2)

Multiplies component by component.

[Version(1, 4, 4)]
public static Vector2 HadamardMod(this Vector2 thisVector, Vector2 otherVector)

Parameters

thisVector Vector2

The this vector.

otherVector Vector2

The other vector.

Returns

Vector2

HadamardMod(Vector3, Vector3)

Multiplies component by component.

[Version(2, 0, 0)]
public static Vector3 HadamardMod(this Vector3 thisVector, Vector3 otherVector)

Parameters

thisVector Vector3

The this vector.

otherVector Vector3

The other vector.

Returns

Vector3

HadamardMod(Vector4, Vector4)

Multiplies component by component.

[Version(2, 0, 0)]
public static Vector4 HadamardMod(this Vector4 thisVector, Vector4 otherVector)

Parameters

thisVector Vector4

The this vector.

otherVector Vector4

The other vector.

Returns

Vector4

HadamardMul(Vector2, Vector2)

Multiplies one vector componentwise by another.

[Version(1, 4, 4)]
public static Vector2 HadamardMul(this Vector2 thisVector, Vector2 otherVector)

Parameters

thisVector Vector2
otherVector Vector2

Returns

Vector2

HadamardMul(Vector3, Vector3)

Multiplies one vector component by another.

[Version(1, 4, 4)]
public static Vector3 HadamardMul(this Vector3 thisVector, Vector3 otherVector)

Parameters

thisVector Vector3
otherVector Vector3

Returns

Vector3

HadamardMul(Vector4, Vector4)

Multiplies one vector component by another.

[Version(1, 4, 4)]
public static Vector4 HadamardMul(this Vector4 thisVector, Vector4 otherVector)

Parameters

thisVector Vector4
otherVector Vector4

Returns

Vector4

Perp(Vector2)

Returns the vector rotated 90 degrees counter-clockwise.

public static Vector2 Perp(this Vector2 vector)

Parameters

vector Vector2

Returns

Vector2

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

vector1 Vector2

The first operand.

vector2 Vector2

The second operand.

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

Vector3

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

Vector3

Proj(Vector2, Vector2)

Returns the projection of this vector onto the given base.

public static Vector2 Proj(this Vector2 vector, Vector2 baseVector)

Parameters

vector Vector2
baseVector Vector2

Returns

Vector2

Proj(Vector3, Vector3)

Returns the projection of this vector onto the given base.

public static Vector3 Proj(this Vector3 vector, Vector3 baseVector)

Parameters

vector Vector3
baseVector Vector3

Returns

Vector3

Proj(Vector4, Vector4)

Returns the projection of this vector onto the given base.

public static Vector4 Proj(this Vector4 vector, Vector4 baseVector)

Parameters

vector Vector4
baseVector Vector4

Returns

Vector4

ReflectAboutX(Vector2)

Reflects the vector about x-axis.

[Version(2, 1, 0)]
public static Vector2 ReflectAboutX(this Vector2 vector)

Parameters

vector Vector2

Returns

Vector2

ReflectAboutY(Vector2)

Reflects the vector about y-axis.

[Version(2, 1, 0)]
public static Vector2 ReflectAboutY(this Vector2 vector)

Parameters

vector Vector2

Returns

Vector2

Rej(Vector2, Vector2)

Returns the rejection of this vector onto the given base.

public static Vector2 Rej(this Vector2 vector, Vector2 baseVector)

Parameters

vector Vector2
baseVector Vector2

Returns

Vector2

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

vector Vector3
baseVector Vector3

Returns

Vector3

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

vector Vector4
baseVector Vector4

Returns

Vector4

Rotate(Vector2, float)

Rotates a vector by a given angle.

public static Vector2 Rotate(this Vector2 vector, float angleInDeg)

Parameters

vector Vector2

vector to rotate

angleInDeg float

angle in degrees.

Returns

Vector2

Rotated vector.

Rotate180(Vector2)

Rotates a vector by 180 degrees.

public static Vector2 Rotate180(this Vector2 vector)

Parameters

vector Vector2

Returns

Vector2

Rotate270(Vector2)

Rotates a vector by 270 degrees.

public static Vector2 Rotate270(this Vector2 vector)

Parameters

vector Vector2

Returns

Vector2

Rotate90(Vector2)

Rotates a vector by 90 degrees.

public static Vector2 Rotate90(this Vector2 vector)

Parameters

vector Vector2

Returns

Vector2

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

vector Vector2
angleInDeg float
axisPosition Vector2

Returns

Vector2

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

Vector2

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

Vector2

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

Vector2

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

Vector3

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

vector Vector2
z float

Returns

Vector3

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

Vector3

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

vector Vector2
y float

Returns

Vector3

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

Vector3

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

vector Vector2
x float

Returns

Vector3

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

vector Vector2
xInc float

Returns

Vector2

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

vector Vector3
xInc float

Returns

Vector3

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

vector Vector2
yInc float

Returns

Vector2

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

vector Vector3
yInc float

Returns

Vector3

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

vector Vector3
zInc float

Returns

Vector3

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

vector Vector2
x float

Returns

Vector2

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

vector Vector3
x float

Returns

Vector3

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

vector Vector2
y float

Returns

Vector2

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

vector Vector3
y float

Returns

Vector3

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

vector Vector3
z float

Returns

Vector3

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

Vector3

YX(Vector2)

Swaps the x and y coordinates of the vector.

public static Vector2 YX(this Vector2 vector)

Parameters

vector Vector2

Returns

Vector2

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

Vector3

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

Vector3

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

Vector3

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

Returns

Vector3