Search Results for

    Show / Hide Table of Contents

    Struct Vector2

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

    Constructors

    | Improve this Doc View Source

    Vector2(Single, Single)

    Initializes a new instance of the Vector2 class.

    Declaration
    public Vector2(float x, float y)
    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.

    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.

    Properties

    | Improve this Doc View Source

    Down

    Returns the down vector. (0,-1)

    Declaration
    public static readonly Vector2 Down { get; }
    Property Value
    Type Description
    Vector2
    | 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 and 1 for the Y component.

    Property Value
    Type Description
    Single

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

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

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

    | Improve this Doc View Source

    Left

    Returns the left vector. (-1,0)

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

    Normalized

    Returns this vector with a magnitude of 1.

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

    Right

    Returns the right vector. (1,0)

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

    UnitX

    The X unit Vector2 (1, 0).

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

    UnitY

    The Y unit Vector2 (0, 1).

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

    Up

    Returns the up vector. (0,1)

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

    Zero

    Returns a null vector. (0,0)

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

    Methods

    | Improve this Doc View Source

    Add(Vector2, Vector2)

    Adds two vectors.

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

    The first vector to add.

    Vector2 right

    The second vector to add.

    Returns
    Type Description
    Vector2

    The sum of the two vectors.

    | Improve this Doc View Source

    Angle(Vector2, Vector2)

    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(Vector2 from, Vector2 to)
    Parameters
    Type Name Description
    Vector2 from
    Vector2 to
    Returns
    Type Description
    Single
    | Improve this Doc View Source

    Clamp(Vector2, Vector2, Vector2)

    Restricts a value to be within a specified range.

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

    The value to clamp.

    Vector2 min

    The minimum value.

    Vector2 max

    The maximum value.

    Returns
    Type Description
    Vector2

    The clamped value.

    | Improve this Doc View Source

    Distance(Vector2, Vector2)

    Calculates the distance between two vectors.

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

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

    Vector2 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(Vector2, Vector2)

    Calculates the squared distance between two vectors.

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

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

    Vector2 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(Vector2)

    Calculates the distance between two vectors.

    Declaration
    public float DistanceTo(Vector2 position)
    Parameters
    Type Name Description
    Vector2 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(Vector2)

    Calculates the squared distance between two vectors.

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

    The second vector to calculate the squared distance to.

    Returns
    Type Description
    Single

    The squared distance to the other vector.

    | Improve this Doc View Source

    Divide(Vector2, Single)

    Scales a vector by the given value.

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

    The vector to scale.

    Single scale

    The amount by which to scale the vector.

    Returns
    Type Description
    Vector2

    The scaled vector.

    | Improve this Doc View Source

    Dot(Vector2, Vector2)

    Calculates the dot product of two vectors.

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

    First source vector.

    Vector2 right

    Second source vector.

    Returns
    Type Description
    Single

    The dot product of the two vectors.

    | Improve this Doc View Source

    Equals(Vector2)

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

    Declaration
    public bool Equals(Vector2 other)
    Parameters
    Type Name Description
    Vector2 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; otherwise, false.

    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(Vector2, Vector2, Single)

    Performs a linear interpolation between two vectors.

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

    Start vector.

    Vector2 end

    End vector.

    Single amount

    Value between 0 and 1 indicating the weight of end.

    Returns
    Type Description
    Vector2

    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(Vector2, Vector2)

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

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

    The first source vector.

    Vector2 right

    The second source vector.

    Returns
    Type Description
    Vector2

    A vector containing the largest components of the source vectors.

    | Improve this Doc View Source

    Minimize(Vector2, Vector2)

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

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

    The first source vector.

    Vector2 right

    The second source vector.

    Returns
    Type Description
    Vector2

    A vector containing the smallest components of the source vectors.

    | Improve this Doc View Source

    Multiply(Vector2, Vector2)

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

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

    The first vector to multiply.

    Vector2 right

    The second vector to multiply.

    Returns
    Type Description
    Vector2

    The multiplied vector.

    | Improve this Doc View Source

    Multiply(Vector2, Single)

    Scales a vector by the given value.

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

    The vector to scale.

    Single scale

    The amount by which to scale the vector.

    Returns
    Type Description
    Vector2

    The scaled vector.

    | Improve this Doc View Source

    Negate(Vector2)

    Reverses the direction of a given vector.

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

    The vector to negate.

    Returns
    Type Description
    Vector2

    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(Vector2)

    Converts the vector into a unit vector.

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

    The vector to normalize.

    Returns
    Type Description
    Vector2

    The normalized vector.

    | Improve this Doc View Source

    RandomXY()

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

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

    Reflect(Vector2, Vector2)

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

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

    The source vector.

    Vector2 normal

    Normal of the surface.

    Returns
    Type Description
    Vector2

    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

    SignedAngle(Vector2, Vector2)

    Returns the signed angle in degrees between from and to.

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

    Subtract(Vector2, Vector2)

    Subtracts two vectors.

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

    The first vector to subtract.

    Vector2 right

    The second vector to subtract.

    Returns
    Type Description
    Vector2

    The difference of the two vectors.

    | 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 format.

    Returns
    Type Description
    String

    The string representation of the value of this instance.

    Operators

    | Improve this Doc View Source

    Addition(Vector2, Vector2)

    Adds two vectors.

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

    The first vector to add.

    Vector2 right

    The second vector to add.

    Returns
    Type Description
    Vector2

    The sum of the two vectors.

    | Improve this Doc View Source

    Division(Vector2, Single)

    Scales a vector by the given value.

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

    The vector to scale.

    Single scale

    The amount by which to scale the vector.

    Returns
    Type Description
    Vector2

    The scaled vector.

    | Improve this Doc View Source

    Equality(Vector2, Vector2)

    Tests for equality between two objects.

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

    The first value to compare.

    Vector2 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(Vector2 to Vector3)

    Converts a Vector2 to a Vector3 implicitly.

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

    Inequality(Vector2, Vector2)

    Tests for inequality between two objects.

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

    The first value to compare.

    Vector2 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(Vector2, Single)

    Scales a vector by the given value.

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

    The vector to scale.

    Single scale

    The amount by which to scale the vector.

    Returns
    Type Description
    Vector2

    The scaled vector.

    | Improve this Doc View Source

    Multiply(Single, Vector2)

    Scales a vector by the given value.

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

    The amount by which to scale the vector.

    Vector2 vector

    The vector to scale.

    Returns
    Type Description
    Vector2

    The scaled vector.

    | Improve this Doc View Source

    Subtraction(Vector2, Vector2)

    Subtracts two vectors.

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

    The first vector to subtract.

    Vector2 right

    The second vector to subtract.

    Returns
    Type Description
    Vector2

    The difference of the two vectors.

    | Improve this Doc View Source

    UnaryNegation(Vector2)

    Reverses the direction of a given vector.

    Declaration
    public static Vector2 operator -(Vector2 value)
    Parameters
    Type Name Description
    Vector2 value

    The vector to negate.

    Returns
    Type Description
    Vector2

    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