Vector4class

A 4-dimensional vector/point.

objectVector4
Namespace
global
Assembly
Sandbox.System
Declaration
public sealed struct Vector4

Constructors5

Showing 5 constructors

Methods29

Showing 29 methods

public bool AlmostEqual(Vector4 v, float delta = 0.0001)PUBLIC

Returns true if we're nearly equal to the passed vector.

ParameterTypeDescription
vVector4The value to compare with
delta = 0.0001floatThe max difference between component values
Returns:boolTrue if nearly equal

public Vector4 ComponentMax(Vector4 other)PUBLIC

Returns a vector that has the maximum values on each axis between this vector and given vector.

ParameterTypeDescription
otherVector4
Returns:Vector4

public Vector4 ComponentMin(Vector4 other)PUBLIC

Returns a vector that has the minimum values on each axis between this vector and given vector.

ParameterTypeDescription
otherVector4
Returns:Vector4

public float Distance(Vector4 target)PUBLIC

Returns distance between this vector to given vector.

ParameterTypeDescription
targetVector4
Returns:float

public static float DistanceBetweenSquared(Vector4 a, Vector4 b)PUBLICSTATIC

Returns squared distance between the 2 given vectors. This is faster than DistanceBetween, and can be used for things like comparing distances, as long as only squared values are used.

ParameterTypeDescription
aVector4
bVector4
Returns:float

public float DistanceSquared(Vector4 target)PUBLIC

Returns squared distance between this vector to given vector. This is faster than Distance, and can be used for things like comparing distances, as long as only squared values are used.

ParameterTypeDescription
targetVector4
Returns:float

public bool IsNearlyZero(float tolerance = 0.0001)PUBLIC

Returns true if value on every axis is less than tolerance away from zero

ParameterTypeDescription
tolerance = 0.0001float
Returns:bool

public Vector4 SnapToGrid(float gridSize, bool sx = True, bool sy = True, bool sz = True, bool sw = True)PUBLIC

Snap to grid along any of the 4 axes.

ParameterTypeDescription
gridSizefloat
sx = Truebool
sy = Truebool
sz = Truebool
sw = Truebool
Returns:Vector4

public static void Sort(Vector4 min, Vector4 max)PUBLICSTATIC

Sort these two vectors into min and max. This doesn't just swap the vectors, it sorts each component. So that min will come out containing the minimum x, y, z and w values.

ParameterTypeDescription
minVector4
maxVector4
Returns:void

public Vector4 WithW(float w)PUBLIC

Returns this vector with given W component.

ParameterTypeDescription
wfloatThe override for W component.
Returns:Vector4The new vector.

public Vector4 WithX(float x)PUBLIC

Returns this vector with given X component.

ParameterTypeDescription
xfloatThe override for X component.
Returns:Vector4The new vector.

public Vector4 WithY(float y)PUBLIC

Returns this vector with given Y component.

ParameterTypeDescription
yfloatThe override for Y component.
Returns:Vector4The new vector.

public Vector4 WithZ(float z)PUBLIC

Returns this vector with given Z component.

ParameterTypeDescription
zfloatThe override for Z component.
Returns:Vector4The new vector.

Properties10

Showing 10 properties

public bool Vector4.IsInfinity { get; set; }PUBLICGETSET

Returns true if x, y, z or w are infinity

Returns:bool

public bool Vector4.IsNaN { get; set; }PUBLICGETSET

Returns true if x, y, z or w are NaN

Returns:bool

public bool Vector4.IsNearZeroLength { get; set; }PUBLICGETSET

Whether length of this vector is nearly zero.

Returns:bool

public float Vector4.Item { get; set; }PUBLICGETSET

Returns:float

public float Vector4.Length { get; set; }PUBLICGETSET

The length (or magnitude) of the vector (Distance from 0,0,0).

Returns:float

public float Vector4.LengthSquared { get; set; }PUBLICGETSET

Squared length of the vector. This is faster than `Vector4.Length`, and can be used for things like comparing distances, as long as only squared values are used.

Returns:float

public float Vector4.w { get; set; }PUBLICGETSET

The W component of this Vector.

Returns:float

public float Vector4.x { get; set; }PUBLICGETSET

The X component of this Vector.

Returns:float

public float Vector4.y { get; set; }PUBLICGETSET

The Y component of this Vector.

Returns:float

public float Vector4.z { get; set; }PUBLICGETSET

The Z component of this Vector.

Returns:float

On this page

Constructorspublic Vector4(System.Numerics.Vector4 v)public Vector4(System.Single x, System.Single y, System.Single z, System.Single w)public Vector4(System.Single all = 0)public Vector4(Vector3 v, System.Single w = 0)public Vector4(Vector4 other)Methodspublic System.Boolean AlmostEqual(Vector4 v, System.Single delta = 0.0001)public Vector4 Clamp(System.Single min, System.Single max)public Vector4 Clamp(Vector4 otherMin, Vector4 otherMax)public static Vector4 Clamp(Vector4 value, Vector4 min, Vector4 max)public Vector4 ComponentMax(Vector4 other)public Vector4 ComponentMin(Vector4 other)public System.Single Distance(Vector4 target)public static System.Single DistanceBetween(Vector4 a, Vector4 b)public static System.Single DistanceBetweenSquared(Vector4 a, Vector4 b)public System.Single DistanceSquared(Vector4 target)public static System.Single Dot(Vector4 a, Vector4 b)public System.Single Dot(Vector4 b)public System.Boolean IsNearlyZero(System.Single tolerance = 0.0001)public static Vector4 Lerp(Vector4 a, Vector4 b, System.Single frac, System.Boolean clamp = True)public static Vector4 Lerp(Vector4 a, Vector4 b, Vector4 frac, System.Boolean clamp = True)public Vector4 LerpTo(Vector4 target, System.Single frac, System.Boolean clamp = True)public Vector4 LerpTo(Vector4 target, Vector4 frac, System.Boolean clamp = True)public static Vector4 Max(Vector4 a, Vector4 b)public Vector4 Min(Vector4 a, Vector4 b)public static override Vector4 Parse(System.String str, System.IFormatProvider provider)public static Vector4 Parse(System.String str)public Vector4 SnapToGrid(System.Single gridSize, System.Boolean sx = True, System.Boolean sy = True, System.Boolean sz = True, System.Boolean sw = True)public static System.Void Sort(Vector4 min, Vector4 max)public static override System.Boolean TryParse(System.String str, System.IFormatProvider provider, Vector4 result)public static System.Boolean TryParse(System.String str, Vector4 result)public Vector4 WithW(System.Single w)public Vector4 WithX(System.Single x)public Vector4 WithY(System.Single y)public Vector4 WithZ(System.Single z)Propertiespublic System.Boolean Vector4.IsInfinity { get; set; }public System.Boolean Vector4.IsNaN { get; set; }public System.Boolean Vector4.IsNearZeroLength { get; set; }public System.Single Vector4.Item { get; set; }public System.Single Vector4.Length { get; set; }public System.Single Vector4.LengthSquared { get; set; }public System.Single Vector4.w { get; set; }public System.Single Vector4.x { get; set; }public System.Single Vector4.y { get; set; }public System.Single Vector4.z { get; set; }Metadata