Search Results for

    Show / Hide Table of Contents

    Struct Vector3

    Implements
    IEquatable<Vector3>
    Inherited Members
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    Namespace: GTA.Math
    Assembly: ScriptHookVDotNet3.dll
    Syntax
    [Serializable]
    public struct Vector3 : IEquatable<Vector3>

    Constructors

    | Improve this Doc View Source

    Vector3(Single, Single, Single)

    Initializes a new instance of the Vector3 class.

    Declaration
    public Vector3(float x, float y, float z)
    Parameters
    Type Name Description
    Single x

    Initial value for the X component of the vector.

    Single y

    Initial value for the Y component of the vector.

    Single z

    Initial value for the Z component of the vector.

    Fields

    | Improve this Doc View Source

    X

    Gets or sets the X component of the vector.

    Declaration
    public float X
    Field Value
    Type Description
    Single

    The X component of the vector.

    | Improve this Doc View Source

    Y

    Gets or sets the Y component of the vector.

    Declaration
    public float Y
    Field Value
    Type Description
    Single

    The Y component of the vector.

    | Improve this Doc View Source

    Z

    Gets or sets the Z component of the vector.

    Declaration
    public float Z
    Field Value
    Type Description
    Single

    The Z component of the vector.

    Properties

    | Improve this Doc View Source

    Item[Int32]

    Gets or sets the component at the specified index.

    Declaration
    public float this[int index] { get; set; }
    Parameters
    Type Name Description
    Int32 index

    The index of the component to access. Use 0 for the X component, 1 for the Y component and 2 for the Z component.

    Property Value
    Type Description
    Single

    The value of the X, Y or Z component, depending on the index.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    Thrown when the index is out of the range [0, 2].

    | Improve this Doc View Source

    Normalized

    Returns this vector with a magnitude of 1.

    Declaration
    public readonly Vector3 Normalized { get; }
    Property Value
    Type Description
    Vector3
    | Improve this Doc View Source

    RelativeBack

    Returns the relative Back vector. (0,-1,0)

    Declaration
    public static readonly Vector3 RelativeBack { get; }
    Property Value
    Type Description
    Vector3
    | Improve this Doc View Source

    RelativeBottom

    Returns the relative Bottom vector as used. (0,0,-1)

    Declaration
    public static readonly Vector3 RelativeBottom { get; }
    Property Value
    Type Description
    Vector3
    | Improve this Doc View Source

    RelativeFront

    Returns the relative Front vector. (0,1,0)

    Declaration
    public static readonly Vector3 RelativeFront { get; }
    Property Value
    Type Description
    Vector3
    | Improve this Doc View Source

    RelativeLeft

    Returns the relative Left vector. (-1,0,0)

    Declaration
    public static readonly Vector3 RelativeLeft { get; }
    Property Value
    Type Description
    Vector3
    | Improve this Doc View Source

    RelativeRight

    Returns the relative Right vector. (1,0,0)

    Declaration
    public static readonly Vector3 RelativeRight { get; }
    Property Value
    Type Description
    Vector3
    | Improve this Doc View Source

    RelativeTop

    Returns the relative Top vector. (0,0,1)

    Declaration
    public static readonly Vector3 RelativeTop { get; }
    Property Value
    Type Description
    Vector3
    | Improve this Doc View Source

    UnitX

    The X unit Vector3 (1, 0, 0).

    Declaration
    public static readonly Vector3 UnitX { get; }
    Property Value
    Type Description
    Vector3
    | Improve this Doc View Source

    UnitY

    The Y unit Vector3 (0, 1, 0).

    Declaration
    public static readonly Vector3 UnitY { get; }
    Property Value
    Type Description
    Vector3
    | Improve this Doc View Source

    UnitZ

    The Z unit Vector3 (0, 0, 1).

    Declaration
    public static readonly Vector3 UnitZ { get; }
    Property Value
    Type Description
    Vector3
    | Improve this Doc View Source

    WorldDown

    Returns the world Down vector. (0,0,-1)

    Declaration
    public static readonly Vector3 WorldDown { get; }
    Property Value
    Type Description
    Vector3
    | Improve this Doc View Source

    WorldEast

    Returns the world East vector. (1,0,0)

    Declaration
    public static readonly Vector3 WorldEast { get; }
    Property Value
    Type Description
    Vector3
    | Improve this Doc View Source

    WorldNorth

    Returns the world North vector. (0,1,0)

    Declaration
    public static readonly Vector3 WorldNorth { get; }
    Property Value
    Type Description
    Vector3
    | Improve this Doc View Source

    WorldSouth

    Returns the world South vector. (0,-1,0)

    Declaration
    public static readonly Vector3 WorldSouth { get; }
    Property Value
    Type Description
    Vector3
    | Improve this Doc View Source

    WorldUp

    Returns the world Up vector. (0,0,1)

    Declaration
    public static readonly Vector3 WorldUp { get; }
    Property Value
    Type Description
    Vector3
    | Improve this Doc View Source

    WorldWest

    Returns the world West vector. (-1,0,0)

    Declaration
    public static readonly Vector3 WorldWest { get; }
    Property Value
    Type Description
    Vector3
    | Improve this Doc View Source

    Zero

    Returns a null vector. (0,0,0)

    Declaration
    public static readonly Vector3 Zero { get; }
    Property Value
    Type Description
    Vector3

    Methods

    | Improve this Doc View Source

    Add(Vector3, Vector3)

    Adds two vectors.

    Declaration
    public static Vector3 Add(Vector3 left, Vector3 right)
    Parameters
    Type Name Description
    Vector3 left

    The first vector to add.

    Vector3 right

    The second vector to add.

    Returns
    Type Description
    Vector3

    The sum of the two vectors.

    | Improve this Doc View Source

    Angle(Vector3, Vector3)

    Returns the angle in degrees between from and to. The angle returned is always the acute angle between the two vectors.

    Declaration
    public static float Angle(Vector3 from, Vector3 to)
    Parameters
    Type Name Description
    Vector3 from
    Vector3 to
    Returns
    Type Description
    Single
    | Improve this Doc View Source

    Around(Single)

    Creates a random vector inside the circle around this position.

    Declaration
    public Vector3 Around(float distance)
    Parameters
    Type Name Description
    Single distance
    Returns
    Type Description
    Vector3
    | Improve this Doc View Source

    Clamp(Vector3, Vector3, Vector3)

    Restricts a value to be within a specified range.

    Declaration
    public static Vector3 Clamp(Vector3 value, Vector3 min, Vector3 max)
    Parameters
    Type Name Description
    Vector3 value

    The value to clamp.

    Vector3 min

    The minimum value.

    Vector3 max

    The maximum value.

    Returns
    Type Description
    Vector3

    The clamped value.

    | Improve this Doc View Source

    Cross(Vector3, Vector3)

    Calculates the cross product of two vectors.

    Declaration
    public static Vector3 Cross(Vector3 left, Vector3 right)
    Parameters
    Type Name Description
    Vector3 left

    First source vector.

    Vector3 right

    Second source vector.

    Returns
    Type Description
    Vector3

    The cross product of the two vectors.

    | Improve this Doc View Source

    Distance(Vector3, Vector3)

    Calculates the distance between two vectors.

    Declaration
    public static float Distance(Vector3 position1, Vector3 position2)
    Parameters
    Type Name Description
    Vector3 position1

    The first vector to calculate the distance to the second vector.

    Vector3 position2

    The second vector to calculate the distance to the first vector.

    Returns
    Type Description
    Single

    The distance between the two vectors.

    | Improve this Doc View Source

    Distance2D(Vector3, Vector3)

    Calculates the distance between two vectors, ignoring the Z-component.

    Declaration
    public static float Distance2D(Vector3 position1, Vector3 position2)
    Parameters
    Type Name Description
    Vector3 position1

    The first vector to calculate the distance to the second vector.

    Vector3 position2

    The second vector to calculate the distance to the first vector.

    Returns
    Type Description
    Single

    The distance between the two vectors.

    | Improve this Doc View Source

    DistanceSquared(Vector3, Vector3)

    Calculates the squared distance between two vectors.

    Declaration
    public static float DistanceSquared(Vector3 position1, Vector3 position2)
    Parameters
    Type Name Description
    Vector3 position1

    The first vector to calculate the squared distance to the second vector.

    Vector3 position2

    The second vector to calculate the squared distance to the first vector.

    Returns
    Type Description
    Single

    The squared distance between the two vectors.

    | Improve this Doc View Source

    DistanceSquared2D(Vector3, Vector3)

    Calculates the squared distance between two vectors, ignoring the Z-component.

    Declaration
    public static float DistanceSquared2D(Vector3 position1, Vector3 position2)
    Parameters
    Type Name Description
    Vector3 position1

    The first vector to calculate the squared distance to the second vector.

    Vector3 position2

    The second vector to calculate the squared distance to the first vector.

    Returns
    Type Description
    Single

    The squared distance between the two vectors.

    | Improve this Doc View Source

    DistanceTo(Vector3)

    Calculates the distance between two vectors.

    Declaration
    public float DistanceTo(Vector3 position)
    Parameters
    Type Name Description
    Vector3 position

    The second vector to calculate the distance to.

    Returns
    Type Description
    Single

    The distance to the other vector.

    | Improve this Doc View Source

    DistanceTo2D(Vector3)

    Calculates the distance between two vectors, ignoring the Z-component.

    Declaration
    public float DistanceTo2D(Vector3 position)
    Parameters
    Type Name Description
    Vector3 position

    The second vector to calculate the distance to.

    Returns
    Type Description
    Single

    The distance to the other vector.

    | Improve this Doc View Source

    DistanceToSquared(Vector3)

    Calculates the squared distance between two vectors.

    Declaration
    public float DistanceToSquared(Vector3 position)
    Parameters
    Type Name Description
    Vector3 position

    The second vector to calculate the distance to.

    Returns
    Type Description
    Single

    The distance to the other vector.

    | Improve this Doc View Source

    DistanceToSquared2D(Vector3)

    Calculates the squared distance between two vectors, ignoring the Z-component.

    Declaration
    public float DistanceToSquared2D(Vector3 position)
    Parameters
    Type Name Description
    Vector3 position

    The second vector to calculate the squared distance to.

    Returns
    Type Description
    Single

    The distance to the other vector.

    | Improve this Doc View Source

    Divide(Vector3, Single)

    Scales a vector by the given value.

    Declaration
    public static Vector3 Divide(Vector3 value, float scale)
    Parameters
    Type Name Description
    Vector3 value

    The vector to scale.

    Single scale

    The amount by which to scale the vector.

    Returns
    Type Description
    Vector3

    The scaled vector.

    | Improve this Doc View Source

    Dot(Vector3, Vector3)

    Calculates the dot product of two vectors.

    Declaration
    public static float Dot(Vector3 left, Vector3 right)
    Parameters
    Type Name Description
    Vector3 left

    First source vector.

    Vector3 right

    Second source vector.

    Returns
    Type Description
    Single

    The dot product of the two vectors.

    | Improve this Doc View Source

    Equals(Vector3)

    Returns a value that indicates whether the current instance is equal to the specified object.

    Declaration
    public bool Equals(Vector3 other)
    Parameters
    Type Name Description
    Vector3 other

    Object to make the comparison with.

    Returns
    Type Description
    Boolean

    true if the current instance is equal to the specified object; false otherwise.

    | Improve this Doc View Source

    Equals(Object)

    Returns a value that indicates whether the current instance is equal to a specified object.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj

    Object to make the comparison with.

    Returns
    Type Description
    Boolean

    true if the current instance is equal to the specified object; false otherwise.

    Overrides
    ValueType.Equals(Object)
    | Improve this Doc View Source

    GetHashCode()

    Returns the hash code for this instance.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32

    A 32-bit signed integer hash code.

    Overrides
    ValueType.GetHashCode()
    | Improve this Doc View Source

    Length()

    Calculates the length of the vector.

    Declaration
    public float Length()
    Returns
    Type Description
    Single

    The length of the vector.

    | Improve this Doc View Source

    LengthSquared()

    Calculates the squared length of the vector.

    Declaration
    public float LengthSquared()
    Returns
    Type Description
    Single

    The squared length of the vector.

    | Improve this Doc View Source

    Lerp(Vector3, Vector3, Single)

    Performs a linear interpolation between two vectors.

    Declaration
    public static Vector3 Lerp(Vector3 start, Vector3 end, float amount)
    Parameters
    Type Name Description
    Vector3 start

    Start vector.

    Vector3 end

    End vector.

    Single amount

    Value between 0 and 1 indicating the weight of end.

    Returns
    Type Description
    Vector3

    The linear interpolation of the two vectors.

    Remarks

    This method performs the linear interpolation based on the following formula.

    start + (end - start) * amount

    Passing amount a value of 0 will cause start to be returned; a value of 1 will cause end to be returned.

    | Improve this Doc View Source

    Maximize(Vector3, Vector3)

    Returns a vector containing the largest components of the specified vectors.

    Declaration
    public static Vector3 Maximize(Vector3 left, Vector3 right)
    Parameters
    Type Name Description
    Vector3 left

    The first source vector.

    Vector3 right

    The second source vector.

    Returns
    Type Description
    Vector3

    A vector containing the largest components of the source vectors.

    | Improve this Doc View Source

    Minimize(Vector3, Vector3)

    Returns a vector containing the smallest components of the specified vectors.

    Declaration
    public static Vector3 Minimize(Vector3 left, Vector3 right)
    Parameters
    Type Name Description
    Vector3 left

    The first source vector.

    Vector3 right

    The second source vector.

    Returns
    Type Description
    Vector3

    A vector containing the smallest components of the source vectors.

    | Improve this Doc View Source

    Multiply(Vector3, Vector3)

    Multiply a vector with another by performing component-wise multiplication.

    Declaration
    public static Vector3 Multiply(Vector3 left, Vector3 right)
    Parameters
    Type Name Description
    Vector3 left

    The first vector to multiply.

    Vector3 right

    The second vector to multiply.

    Returns
    Type Description
    Vector3

    The multiplied vector.

    | Improve this Doc View Source

    Multiply(Vector3, Single)

    Scales a vector by the given value.

    Declaration
    public static Vector3 Multiply(Vector3 value, float scale)
    Parameters
    Type Name Description
    Vector3 value

    The vector to scale.

    Single scale

    The amount by which to scale the vector.

    Returns
    Type Description
    Vector3

    The scaled vector.

    | Improve this Doc View Source

    Negate(Vector3)

    Reverses the direction of a given vector.

    Declaration
    public static Vector3 Negate(Vector3 value)
    Parameters
    Type Name Description
    Vector3 value

    The vector to negate.

    Returns
    Type Description
    Vector3

    A vector facing in the opposite direction.

    | Improve this Doc View Source

    Normalize()

    Converts the vector into a unit vector.

    Declaration
    public void Normalize()
    | Improve this Doc View Source

    Normalize(Vector3)

    Converts the vector into a unit vector.

    Declaration
    public static Vector3 Normalize(Vector3 vector)
    Parameters
    Type Name Description
    Vector3 vector

    The vector to normalize.

    Returns
    Type Description
    Vector3

    The normalized vector.

    | Improve this Doc View Source

    Project(Vector3, Vector3)

    Projects a vector onto another vector.

    Declaration
    public static Vector3 Project(Vector3 vector, Vector3 onNormal)
    Parameters
    Type Name Description
    Vector3 vector

    The vector to project.

    Vector3 onNormal

    Vector to project onto, does not assume it is normalized.

    Returns
    Type Description
    Vector3

    The projected vector.

    | Improve this Doc View Source

    ProjectOnPlane(Vector3, Vector3)

    Projects a vector onto a plane defined by a normal orthogonal to the plane.

    Declaration
    public static Vector3 ProjectOnPlane(Vector3 vector, Vector3 planeNormal)
    Parameters
    Type Name Description
    Vector3 vector

    The vector to project.

    Vector3 planeNormal

    Normal of the plane, does not assume it is normalized.

    Returns
    Type Description
    Vector3

    The Projection of vector onto plane.

    | Improve this Doc View Source

    RandomXY()

    Returns a new normalized vector with random X and Y components.

    Declaration
    public static Vector3 RandomXY()
    Returns
    Type Description
    Vector3
    | Improve this Doc View Source

    RandomXYZ()

    Returns a new normalized vector with random X, Y and Z components.

    Declaration
    public static Vector3 RandomXYZ()
    Returns
    Type Description
    Vector3
    | Improve this Doc View Source

    Reflect(Vector3, Vector3)

    Returns the reflection of a vector off a surface that has the specified normal.

    Declaration
    public static Vector3 Reflect(Vector3 vector, Vector3 normal)
    Parameters
    Type Name Description
    Vector3 vector

    The vector to project onto the plane.

    Vector3 normal

    Normal of the surface.

    Returns
    Type Description
    Vector3

    The reflected vector.

    Remarks

    Reflect only gives the direction of a reflection off a surface, it does not determine whether the original vector was close enough to the surface to hit it.

    | Improve this Doc View Source

    Round(Int32)

    Rounds each float inside the vector to a select amount of decimal places (2 by default).

    Declaration
    public Vector3 Round(int decimalPlaces = 2)
    Parameters
    Type Name Description
    Int32 decimalPlaces

    Number of decimal places to round to

    Returns
    Type Description
    Vector3

    The vector containing rounded values

    | Improve this Doc View Source

    SignedAngle(Vector3, Vector3, Vector3)

    Returns the signed angle in degrees between from and to.

    Declaration
    public static float SignedAngle(Vector3 from, Vector3 to, Vector3 planeNormal)
    Parameters
    Type Name Description
    Vector3 from
    Vector3 to
    Vector3 planeNormal
    Returns
    Type Description
    Single
    | Improve this Doc View Source

    Subtract(Vector3, Vector3)

    Subtracts two vectors.

    Declaration
    public static Vector3 Subtract(Vector3 left, Vector3 right)
    Parameters
    Type Name Description
    Vector3 left

    The first vector to subtract.

    Vector3 right

    The second vector to subtract.

    Returns
    Type Description
    Vector3

    The difference of the two vectors.

    | Improve this Doc View Source

    ToArray()

    Converts the matrix to an array of floats.

    Declaration
    public float[] ToArray()
    Returns
    Type Description
    Single[]
    | Improve this Doc View Source

    ToHeading()

    Converts a vector to a heading.

    Declaration
    public float ToHeading()
    Returns
    Type Description
    Single
    | Improve this Doc View Source

    ToString()

    Converts the value of the object to its equivalent string representation.

    Declaration
    public override string ToString()
    Returns
    Type Description
    String

    The string representation of the value of this instance.

    Overrides
    ValueType.ToString()
    | Improve this Doc View Source

    ToString(String)

    Converts the value of the object to its equivalent string representation.

    Declaration
    public string ToString(string format)
    Parameters
    Type Name Description
    String format

    The number format.

    Returns
    Type Description
    String

    The string representation of the value of this instance.

    Operators

    | Improve this Doc View Source

    Addition(Vector3, Vector3)

    Adds two vectors.

    Declaration
    public static Vector3 operator +(Vector3 left, Vector3 right)
    Parameters
    Type Name Description
    Vector3 left

    The first vector to add.

    Vector3 right

    The second vector to add.

    Returns
    Type Description
    Vector3

    The sum of the two vectors.

    | Improve this Doc View Source

    Division(Vector3, Single)

    Scales a vector by the given value.

    Declaration
    public static Vector3 operator /(Vector3 vector, float scale)
    Parameters
    Type Name Description
    Vector3 vector

    The vector to scale.

    Single scale

    The amount by which to scale the vector.

    Returns
    Type Description
    Vector3

    The scaled vector.

    | Improve this Doc View Source

    Equality(Vector3, Vector3)

    Tests for equality between two objects.

    Declaration
    public static bool operator ==(Vector3 left, Vector3 right)
    Parameters
    Type Name Description
    Vector3 left

    The first value to compare.

    Vector3 right

    The second value to compare.

    Returns
    Type Description
    Boolean

    true if left has the same value as right; otherwise, false.

    | Improve this Doc View Source

    Implicit(Vector3 to Vector2)

    Converts a Vector3 to a Vector2 implicitly.

    Declaration
    public static implicit operator Vector2(Vector3 vector)
    Parameters
    Type Name Description
    Vector3 vector
    Returns
    Type Description
    Vector2
    | Improve this Doc View Source

    Inequality(Vector3, Vector3)

    Tests for inequality between two objects.

    Declaration
    public static bool operator !=(Vector3 left, Vector3 right)
    Parameters
    Type Name Description
    Vector3 left

    The first value to compare.

    Vector3 right

    The second value to compare.

    Returns
    Type Description
    Boolean

    true if left has a different value than right; otherwise, false.

    | Improve this Doc View Source

    Multiply(Vector3, Single)

    Scales a vector by the given value.

    Declaration
    public static Vector3 operator *(Vector3 vector, float scale)
    Parameters
    Type Name Description
    Vector3 vector

    The vector to scale.

    Single scale

    The amount by which to scale the vector.

    Returns
    Type Description
    Vector3

    The scaled vector.

    | Improve this Doc View Source

    Multiply(Single, Vector3)

    Scales a vector by the given value.

    Declaration
    public static Vector3 operator *(float scale, Vector3 vector)
    Parameters
    Type Name Description
    Single scale

    The amount by which to scale the vector.

    Vector3 vector

    The vector to scale.

    Returns
    Type Description
    Vector3

    The scaled vector.

    | Improve this Doc View Source

    Subtraction(Vector3, Vector3)

    Subtracts two vectors.

    Declaration
    public static Vector3 operator -(Vector3 left, Vector3 right)
    Parameters
    Type Name Description
    Vector3 left

    The first vector to subtract.

    Vector3 right

    The second vector to subtract.

    Returns
    Type Description
    Vector3

    The difference of the two vectors.

    | Improve this Doc View Source

    UnaryNegation(Vector3)

    Reverses the direction of a given vector.

    Declaration
    public static Vector3 operator -(Vector3 vector)
    Parameters
    Type Name Description
    Vector3 vector

    The vector to negate.

    Returns
    Type Description
    Vector3

    A vector facing in the opposite direction.

    Implements

    System.IEquatable<T>
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX