Struct Vector4
Vector in 4D.
public struct Vector4 : IEquatable<Vector4>
Remarks
Not to be confused with UnityEngine's Vector4. For all operation in Engine4, Vector4 refers to this struct. We create the duplicate because UnityEngine's variant is lack of static utilities.
Constructors
Vector4(Int32, Single)
Create an euler data with a value for given axis index.
public Vector4(int axis, float value)
Remarks
See Item[Int32] for axis index. Other axis will set as zero by default
Vector4(Single)
Create a uniform vector.
public Vector4(float scale)
Vector4(Single, Single, Single, Single)
Create a new vector data with given individual values.
public Vector4(float x, float y, float z, float w)
Fields
w
W axis of the vector
public float w
x
X axis of the vector
public float x
y
Y axis of the vector
public float y
z
Z axis of the vector
public float z
Properties
forward
The vector pointing to front direction
public static Vector4 forward { get; }
Item[Int32]
Get or set a vector value in given axis index
public float this[int i] { get; set; }
Remarks
Axis index in order: X, Y, Z, W.
one
Vector with values of one
public static Vector4 one { get; }
overward
The vector pointing to over direction
public static Vector4 overward { get; }
rightward
The vector pointing to right direction
public static Vector4 rightward { get; }
upward
The vector pointing to up direction
public static Vector4 upward { get; }
zero
Vector with zero values
public static Vector4 zero { get; }
Methods
Abs(Vector4)
Get the absolute version of the vector
public static Vector4 Abs(Vector4 v)
Clamp(Vector4, Vector4, Vector4)
Clamp vector T between A and B.
public static Vector4 Clamp(Vector4 a, Vector4 b, Vector4 t)
ComputeBasis(Vector4[])
public static void ComputeBasis(Vector4[] vector)
Cross(Vector4, Vector4, Vector4)
Get the cross operation between three vector
public static Vector4 Cross(Vector4 a, Vector4 b, Vector4 c)
Remarks
This cross operation finds the other vector that perpendicular to the three vector. The convention used such that A and B is equivalent to the left hand rule if C is positive overward.
Distance(Vector4, Vector4)
Get the distance between two vector
public static float Distance(Vector4 a, Vector4 b)
DistanceSq(Vector4, Vector4)
Get the squared distance between two vector
public static float DistanceSq(Vector4 a, Vector4 b)
Dot(Vector4, Vector4)
Get the dot operation between two vector
public static float Dot(Vector4 a, Vector4 b)
Invert(Vector4)
Axis-wisely inverse the vector
public static Vector4 Invert(Vector4 v)
See Also
Length(Vector4)
Get the length (magnitude) of the vector
public static float Length(Vector4 v)
LengthSq(Vector4)
Get the squared length of the vector
public static float LengthSq(Vector4 v)
Remarks
This method is much faster, and should be used if it means only for comparison
Lerp(Vector4, Vector4, Single)
Interpolate two vector by T and clamp.
public static Vector4 Lerp(Vector4 a, Vector4 b, float t)
Remarks
The interpolation is clamped between zero to one
LerpUnclamped(Vector4, Vector4, Single)
Interpolate two vector by T
public static Vector4 LerpUnclamped(Vector4 a, Vector4 b, float t)
Remarks
The interpolation is not clamped.
Max(Vector4, Vector4)
Axis-wisely choose the largest range of two vector.
public static Vector4 Max(Vector4 a, Vector4 b)
MaxPerElem(Vector4)
Return the largest axis value in the vector.
public static float MaxPerElem(Vector4 a)
MaxPerElemIdx(Vector4)
Return the axis index that has largest value in the vector.
public static int MaxPerElemIdx(Vector4 a)
Min(Vector4, Vector4)
Axis-wisely choose the smallest range of two vector.
public static Vector4 Min(Vector4 a, Vector4 b)
MinPerElem(Vector4)
Return the smallest axis value in the vector.
public static float MinPerElem(Vector4 a)
MinPerElemIdx(Vector4)
Return the axis index that has smallest value in the vector.
public static int MinPerElemIdx(Vector4 a)
Normalize(Vector4)
Normalize the vector.
public static Vector4 Normalize(Vector4 v)
Sign(Vector4)
Get the sign version of the vector
public static Vector4 Sign(Vector4 n)
Operators
Addition(Vector4, Vector4)
Axis-wisely add two vector values
public static Vector4 operator +(Vector4 lhs, Vector4 rhs)
Division(Vector4, Single)
Axis-wisely divide an euler values with a number
public static Vector4 operator /(Vector4 lhs, float f)
Equality(Vector4, Vector4)
Equivalence check
public static bool operator ==(Vector4 lhs, Vector4 rhs)
GreaterThan(Vector4, Vector4)
Compare if A is greater than B in all axes
public static bool operator>(Vector4 lhs, Vector4 rhs)
Implicit(Vector4 to Vector3)
Implicit conversion from UnityEngine's Vector3
public static implicit operator Vector3(Vector4 v)
Implicit(Vector4 to Vector4)
Implicit conversion to UnityEngine's Vector4
public static implicit operator Vector4(Vector4 v)
Implicit(Vector4 to Vector4)
Implicit conversion from UnityEngine's Vector4
public static implicit operator Vector4(Vector4 v)
Inequality(Vector4, Vector4)
Inequivalence check
public static bool operator !=(Vector4 lhs, Vector4 rhs)
LessThan(Vector4, Vector4)
Compare if A is smaller than B in all axes
public static bool operator <(Vector4 lhs, Vector4 rhs)
Multiply(Vector4, Vector4)
Axis-wisely multiply two vector.
public static Vector4 operator *(Vector4 a, Vector4 b)
Multiply(Vector4, Single)
Axis-wisely scale an euler values with a number
public static Vector4 operator *(Vector4 lhs, float f)
Multiply(Single, Vector4)
Axis-wisely scale an euler values with a number
public static Vector4 operator *(float f, Vector4 lhs)
Subtraction(Vector4, Vector4)
Axis-wisely subtract two euler values
public static Vector4 operator -(Vector4 lhs, Vector4 rhs)
UnaryNegation(Vector4)
Negate each vector axis
public static Vector4 operator -(Vector4 lhs)