s&box docs

public sealed struct Vector4

A 4-dimensional vector/point.

Broader workflow and conceptual references connected to this API.

Constructors

Showing 5 constructors

Methods

Showing 29 methods

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

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

Parameters

  • v: The value to compare with
  • delta: The max difference between component values Default: 0.0001

Returns

True if nearly equal

public Vector4 ComponentMax(Vector4 other)

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

public Vector4 ComponentMin(Vector4 other)

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

public float Distance(Vector4 target)

Returns distance between this vector to given vector.

public static float DistanceBetweenSquared(Vector4 a, Vector4 b)

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.

public float DistanceSquared(Vector4 target)

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.

public bool IsNearlyZero(float tolerance = 0.0001)

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

Parameters

  • tolerance: Default: 0.0001

public static Vector4 Max(Vector4 a, Vector4 b)

Returns a vector that has the maximum values on each axis between the 2 given vectors.

public Vector4 Min(Vector4 a, Vector4 b)

Returns a vector that has the minimum values on each axis between the 2 given vectors.

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

Snap to grid along any of the 4 axes.

Parameters

  • sx: Default: True
  • sy: Default: True
  • sz: Default: True
  • sw: Default: True

public static void Sort(Vector4 min, Vector4 max)

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.

public Vector4 WithW(float w)

Returns this vector with given W component.

Parameters

  • w: The override for W component.

Returns

The new vector.

public Vector4 WithX(float x)

Returns this vector with given X component.

Parameters

  • x: The override for X component.

Returns

The new vector.

public Vector4 WithY(float y)

Returns this vector with given Y component.

Parameters

  • y: The override for Y component.

Returns

The new vector.

public Vector4 WithZ(float z)

Returns this vector with given Z component.

Parameters

  • z: The override for Z component.

Returns

The new vector.

Properties

Showing 10 properties

public bool Vector4.IsInfinity { get; set; }

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

public bool Vector4.IsNaN { get; set; }

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

public bool Vector4.IsNearZeroLength { get; set; }

Whether length of this vector is nearly zero.

public float Vector4.Length { get; set; }

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

public float Vector4.LengthSquared { get; set; }

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.

public float Vector4.w { get; set; }

The W component of this Vector.

public float Vector4.x { get; set; }

The X component of this Vector.

public float Vector4.y { get; set; }

The Y component of this Vector.

public float Vector4.z { get; set; }

The Z component of this Vector.

Metadata

FieldValue
Namespaceglobal
Typeclass
AssemblySandbox.System
Doc IDT:Vector4

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