# Vector3

A 3-dimentional vector. Typically represents a position, size, or direction in 3D space.

- Kind: struct
- Assembly: `Sandbox.System`
- Modifiers: sealed

## Constructors

- [`Vector3`](/api/Vector3/.ctor): Initializes a vector with given components.

## Fields

- [`Backward`](/api/Vector3/Backward): A vector with X set to -1. This represents the backwards direction.
- [`Down`](/api/Vector3/Down): A vector with Z set to -1. This represents the downwards direction.
- [`Forward`](/api/Vector3/Forward): A vector with X set to 1. This represents the forwards direction.
- [`Left`](/api/Vector3/Left): A vector with Y set to 1. This represents the left hand direction.
- [`One`](/api/Vector3/One): A vector with all components set to 1.
- [`Right`](/api/Vector3/Right): A vector with Y set to -1. This represents the right hand direction.
- [`Up`](/api/Vector3/Up): A vector with Z set to 1. This represents the upwards direction.
- [`Zero`](/api/Vector3/Zero): A vector with all components set to 0.

## Properties

- [`EulerAngles`](/api/Vector3/EulerAngles): The Euler angles of this direction vector.
- [`Inverse`](/api/Vector3/Inverse): Returns the inverse of this vector, which is useful for scaling vectors.
- [`IsFinite`](/api/Vector3/IsFinite): Returns true if x, y and z are all finite, so neither NaN nor infinity
- [`IsInfinity`](/api/Vector3/IsInfinity): Returns true if x, y or z are infinity
- [`IsNaN`](/api/Vector3/IsNaN): Returns true if x, y or z are NaN
- [`IsNearZeroLength`](/api/Vector3/IsNearZeroLength): Returns true if the squared length is less than 1e-8 (which is really near zero)
- [`Item`](/api/Vector3/Item)
- [`Length`](/api/Vector3/Length): Length (or magnitude) of the vector (Distance from 0,0,0).
- [`LengthSquared`](/api/Vector3/LengthSquared): Squared length of the vector. This is faster than [Length](/api/Vector3/Length), and can be used for things like comparing distances, as long as only squared values are used.
- [`Normal`](/api/Vector3/Normal): Returns a unit version of this vector. A unit vector has length of 1.
- [`Random`](/api/Vector3/Random): Uniformly samples a 3D position from all points with distance at most 1 from the origin.
- [`x`](/api/Vector3/x): The X component of this vector.
- [`y`](/api/Vector3/y): The Y component of this vector.
- [`z`](/api/Vector3/z): The Z component of this vector.

## Methods

- [`Abs`](/api/Vector3/Abs): Returns a new vector with all values positive. -5 becomes 5, etc.
- [`AddClamped`](/api/Vector3/AddClamped): 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.
- [`AlmostEqual`](/api/Vector3/AlmostEqual): Returns true if we're nearly equal to the passed vector.
- [`Angle`](/api/Vector3/Angle): Return the distance between the two direction vectors in degrees.
- [`Approach`](/api/Vector3/Approach): Returns a new vector whose length is closer to given target length by given amount.
- [`CatmullRomSpline`](/api/Vector3/CatmullRomSpline): Calculates a point on a Catmull-Rom spline given four control points and a parameter t.
- [`Clamp`](/api/Vector3/Clamp): Returns a vector each axis of which is clamped to between the 2 given vectors. Basically clamps a point to an Axis Aligned Bounding Box (AABB).
- [`ClampLength`](/api/Vector3/ClampLength): Returns a vector whose length is limited to given maximum.
- [`ComponentMax`](/api/Vector3/ComponentMax): Returns a vector that has the maximum values on each axis between this vector and given vector.
- [`ComponentMin`](/api/Vector3/ComponentMin): Returns a vector that has the minimum values on each axis between this vector and given vector.
- [`Cross`](/api/Vector3/Cross): Returns the cross product of the 2 given vectors. If the given vectors are linearly independent, the resulting vector is perpendicular to them both, also known as a normal of a plane.
- [`CubicBezier`](/api/Vector3/CubicBezier): Calculates position of a point on a cubic beizer curve at given fraction.
- [`Direction`](/api/Vector3/Direction): Calculates the normalized direction vector from one point to another in 3D space.
- [`Distance`](/api/Vector3/Distance): Returns distance between this vector to given vector.
- [`DistanceBetween`](/api/Vector3/DistanceBetween): Returns distance between the 2 given vectors.
- [`DistanceBetweenSquared`](/api/Vector3/DistanceBetweenSquared): Returns squared distance between the 2 given vectors. This is faster than [DistanceBetween](/api/Vector3/DistanceBetween), and can be used for things like comparing distances, as long as only squared values are used.
- [`DistanceSquared`](/api/Vector3/DistanceSquared): Returns squared distance between this vector to given vector. This is faster than [Distance](/api/Vector3/Distance), and can be used for things like comparing distances, as long as only squared values are used.
- [`Dot`](/api/Vector3/Dot): Returns the scalar/dot product of the 2 given vectors.
- [`GetAngle`](/api/Vector3/GetAngle): Return the distance between the two direction vectors in degrees.
- [`InverseLerp`](/api/Vector3/InverseLerp): Given a position, and two other positions, calculate the inverse lerp position between those
- [`IsNearlyZero`](/api/Vector3/IsNearlyZero): Returns true if value on every axis is less than tolerance away from zero
- [`Lerp`](/api/Vector3/Lerp): Performs linear interpolation between 2 given vectors.
- [`LerpTo`](/api/Vector3/LerpTo): Performs linear interpolation between this and given vectors.
- [`Max`](/api/Vector3/Max): Returns a vector that has the maximum values on each axis between the 2 given vectors.
- [`Min`](/api/Vector3/Min): Returns a vector that has the minimum values on each axis between the 2 given vectors.
- [`Parse`](/api/Vector3/Parse)
- [`ProjectOnNormal`](/api/Vector3/ProjectOnNormal): Projects this vector onto another vector. Basically extends the given normal/unit vector to be as long as necessary to make a right triangle (a triangle which has a 90 degree corner) between (0,0,0), this vector and the projected vector.
- [`Reflect`](/api/Vector3/Reflect): Returns a reflected vector based on incoming direction and plane normal. Like a ray reflecting off of a mirror.
- [`RotateAround`](/api/Vector3/RotateAround): Rotate this vector around given point by given rotation and return the result as a new vector. See [Transform.RotateAround](/api/Transform/RotateAround) for similar method that also transforms rotation.
- [`Slerp`](/api/Vector3/Slerp): Performs spherical linear interpolation (Slerp) between two vectors.
- [`SlerpTo`](/api/Vector3/SlerpTo): Performs spherical linear interpolation (Slerp) between this vector and a target vector.
- [`SmoothDamp`](/api/Vector3/SmoothDamp): Smoothly move towards the target vector
- [`SnapToGrid`](/api/Vector3/SnapToGrid): Snap to grid along any of the 3 axes.
- [`Sort`](/api/Vector3/Sort): 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.
- [`SpringDamp`](/api/Vector3/SpringDamp): Springly move towards the target vector
- [`SubtractDirection`](/api/Vector3/SubtractDirection): 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 subtract by scaling the direction. Ie, passing in a direction with a length of 0.5 will remove half the direction.
- [`TcbSpline`](/api/Vector3/TcbSpline): Calculates an interpolated point using the Kochanek-Bartels spline (TCB spline).
- [`TryParse`](/api/Vector3/TryParse)
- [`VectorAngle`](/api/Vector3/VectorAngle): Converts a direction vector to an angle.
- [`VectorPlaneProject`](/api/Vector3/VectorPlaneProject): Projects given vector on a plane defined by `planeNormal`.
- [`WithAcceleration`](/api/Vector3/WithAcceleration): Move to the target vector, by amount acceleration
- [`WithAimCone`](/api/Vector3/WithAimCone): This direction randomly deflected within a cone `degrees` wide, centred on it. Use for bullet spread. Pass a `random` to control the randomness (e.g. a seeded one, so peers agree on the deflection) - null uses the shared random.
- [`WithFriction`](/api/Vector3/WithFriction): Apply an amount of friction to the current velocity.
- [`WithX`](/api/Vector3/WithX): Returns this vector with given X component.
- [`WithY`](/api/Vector3/WithY): Returns this vector with given Y component.
- [`WithZ`](/api/Vector3/WithZ): Returns this vector with given Z component.
