Vector class, which performs basic 3D vector math operations.
``````    public struct Vector3 : IEquatable<Vector3>
``````

Vector3 is one of the core classes of the engine, and includes several built-in helper functions to perform basic vector math operations.

### Constructors

``````    public Vector3(float x, float y, float z)
``````

Returns a Vector3 with the given components.

``````    public Vector3()
``````

### Fields

``````    public Single x
``````

X component of the vector.

``````    public Single y
``````

Y component of the vector.

``````    public Single z
``````

Z component of the vector.

### Properties

``````    public float this[] { get; set; }
``````

### Methods

``````    public Vector3 Abs()
``````

Returns a new vector with all components in absolute values (i.e. positive).

``````    public float AngleTo(Vector3 to)
``````

Returns the vector’s minimum angle to the vector `to`.

``````    public Vector3 Bounce(Vector3 n)
``````

Bounce returns the vector “bounced off” from the given plane, specified by its normal vector.

``````    public Vector3 Ceil()
``````

Returns a new vector with all components rounded up.

``````    public Vector3 Cross(Vector3 b)
``````

Returns the cross product with `b`.

``````    public Vector3 CubicInterpolate(Vector3 b, Vector3 preA, Vector3 postB, float t)
``````

Performs a cubic interpolation between vectors `preA`, `a`, `b`, `postB` (`a` is current), by the given amount (t). (t) should be a float of 0.0-1.0, a percentage of how far along the interpolation is.

``````    public float DistanceSquaredTo(Vector3 b)
``````

Returns the squared distance to `b`. Prefer this function over distance_to if you need to sort vectors or need the squared distance for some formula.

``````    public float DistanceTo(Vector3 b)
``````

Returns the distance to b.

``````    public float Dot(Vector3 b)
``````

Returns the dot product with b.

``````    public override bool Equals(object obj)
``````

``````    public bool Equals(Vector3 other)
``````

``````    public Vector3 Floor()
``````

Returns a new vector with all components rounded down.

``````    public override int GetHashCode()
``````

``````    public Vector3 Inverse()
``````

Returns the inverse of the vector. This is the same as Vector3( 1.0 / v.x, 1.0 / v.y, 1.0 / v.z )

``````    public bool IsNormalized()
``````

Returns whether the vector is normalized or not.

``````    public float Length()
``````

Returns the length of the vector.

``````    public float LengthSquared()
``````

Returns the length of the vector, squared. Prefer this function over “length” if you need to sort vectors or need the squared length for some formula.

``````    public Vector3 LinearInterpolate(Vector3 b, float t)
``````

Linearly interpolates the vector to a given one (b), by the given amount (t). (t) should be a float of 0.0-1.0, a percentage of how far along the interpolation is.

``````    public Axis MaxAxis()
``````

Returns AXIS_X, AXIS_Y or AXIS_Z depending on which axis is the largest.

``````    public Axis MinAxis()
``````

Returns AXIS_X, AXIS_Y or AXIS_Z depending on which axis is the smallest.

``````    public Vector3 Normalized()
``````

Returns a copy of the normalized vector to unit length. This is the same as v / v.length().

``````    public Basis Outer(Vector3 b)
``````

Returns the outer product with b.

``````    public Vector3 Reflect(Vector3 n)
``````

Reflects the vector along the given plane, specified by its normal vector.

``````    public Vector3 Rotated(Vector3 axis, float phi)
``````

Rotates the vector around some axis by phi radians. The axis must be a normalized vector.

``````    public Vector3 Slide(Vector3 n)
``````

Slide returns the component of the vector along the given plane, specified by its normal vector.

``````    public Vector3 Snapped(Vector3 by)
``````

``````    public Basis ToDiagonalMatrix()
``````

Returns a diagonal matrix with the vector as main diagonal.

``````    public override string ToString()
``````

``````    public string ToString(string format)
``````

### Operators

``````    public static Vector3 operator +(Vector3 left, Vector3 right)
``````

``````    public static Vector3 operator /(Vector3 vec, float scale)
``````

``````    public static Vector3 operator /(Vector3 left, Vector3 right)
``````

``````    public static bool operator ==(Vector3 left, Vector3 right)
``````

``````    public static bool operator >(Vector3 left, Vector3 right)
``````

``````    public static bool operator >=(Vector3 left, Vector3 right)
``````

``````    public static bool operator !=(Vector3 left, Vector3 right)
``````

``````    public static bool operator <(Vector3 left, Vector3 right)
``````

``````    public static bool operator <=(Vector3 left, Vector3 right)
``````

``````    public static Vector3 operator *(Vector3 vec, float scale)
``````

``````    public static Vector3 operator *(float scale, Vector3 vec)
``````

``````    public static Vector3 operator *(Vector3 left, Vector3 right)
``````

``````    public static Vector3 operator -(Vector3 left, Vector3 right)
``````

``````    public static Vector3 operator -(Vector3 vec)
``````

### Inner Types

#### Axis

Name Value Description
X
Y
Z
Tags: