S&box Wiki



static Vector3 Down
static Vector3 Left
static Vector3 One
static Vector3 OneX
static Vector3 OneY
static Vector3 OneZ
static Vector3 Right
static Vector3 Up
static Vector3 Zero


Angles EulerAngles { get; set; }
The euler angle of this vector
bool IsNaN { get; }
Returns true if x, y or z are NaN
bool IsNearZeroLength { get; }
float Item { get; set; }
float Length { get; }
float LengthSquared { get; }
Vector3 Normal { get; }
static Vector3 Random { get; }
bool SafeToNormalize { get; }
float x { get; set; }
float y { get; set; }
float z { get; set; }


Vector3 AddClamped( Vector3 toAdd, float maxLength )
Try to add to this vector. If we're already over max then don't add. If we're over max when we add, clamp in that direction so we're not.
float Angle( Vector3 v2 )
Return the distance between the two direction vectors in degrees
Vector3 Approach( float length, float amount )
Vector3 ClampLength( float maxLength )
float Distance( Vector3 target )
static float DistanceBetween( Vector3 a, Vector3 b )
float Dot( Vector3 b )
static float GetAngle( Vector3 v1, Vector3 v2 )
Return the distance between the two direction vectors in degrees
bool IsNearlyEqual( Vector3 v, float delta = 0.0001 )
Returns true if we're nearly equal to the passed vector.
bool IsNearlyZero( float tolerance = 1E-45 )
Return true if less than tolerance away from zero
static Vector3 Lerp( Vector3 a, Vector3 b, float t, bool clamp = True )
Vector3 LerpTo( Vector3 target, float t )
static Vector3 Max( Vector3 a, Vector3 b )
static Vector3 Min( Vector3 a, Vector3 b )
static Vector3 Parse( string str )
Given a string, try to convert this into a vector. Example input formats that work would be "1,1,1", "1;1;1", "[1 1 1]". This handles a bunch of different seperators ( ' ', ',', ';', '\n', '\r' ). It also trims surrounding characters ('[', ']', ' ', '\n', '\r', '\t', '"').
Vector3 Read( System.IO.BinaryReader reader )
static Vector3 Reflect( Vector3 direction, Vector3 normal )
Vector3 SnapToGrid( float gridSize, bool sx = True, bool sy = True, bool sz = True )
Snap To Grid along all 3 axes
static void Sort( Vector3 min, Vector3 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 and z values.
Vector3 SubtractDirection( Vector3 direction, float strength = 1 )
Given a vector like 1,1,1 and direction 1,0,0, will return 0,1,1. This is useful for velocity collision type events, where you want to cancel out velocity based on a normal. For this to work properly, direction should be a normal, but you can scale how much you want to sutract by scaling the direction. Ie, passing in a direction with a length of 0. 5 will remove half the direction.
static Angles VectorAngle( Vector3 vec )
Converts a vector to an angle
static Vector3 VectorPlaneProject( Vector3 v, Vector3 planeNormal )
Vector3 WithX( float x )
Vector3 WithY( float y )
Vector3 WithZ( float z )
void Write( System.IO.BinaryWriter writer )