Struct Vector
Represents a two-dimensional vector.
public readonly struct Vector
- Inherited Members
Constructors
Vector(float, float)
Represents a two-dimensional vector.
public Vector(float X = 0, float Y = 0)
Parameters
Properties
Magnitude
Gets the magnitude (length) of the vector.
public float Magnitude { get; }
Property Value
Normalized
Gets the normalized (unit-length) vector.
public Vector Normalized { get; }
Property Value
X
Gets the X component of the vector.
public float X { get; }
Property Value
Y
Gets the y component of the vector.
public float Y { get; }
Property Value
Methods
CeilToInt()
Applies ceiling to this vector's components, returning a VectorInt.
public VectorInt CeilToInt()
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
FloorToInt()
Applies floor to this vector's components, returning a VectorInt.
public VectorInt FloorToInt()
Returns
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
RoundToInt()
Rounds this vector's components, returning a VectorInt.
public VectorInt RoundToInt()
Returns
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Operators
operator +(Vector, Vector)
Adds two vectors.
public static Vector operator +(Vector v1, Vector v2)
Parameters
Returns
- Vector
The sum as a vector.
operator /(Vector, float)
Divides a vector by a scalar.
public static Vector operator /(Vector v, float f)
Parameters
Returns
- Vector
The resulting vector.
operator ==(Vector, Vector)
Determines whether two Vector instances are equal.
public static bool operator ==(Vector v1, Vector v2)
Parameters
Returns
- bool
true if the vectors are equal; otherwise, false.
implicit operator Vector((float x, float y))
Creates a Vector from a tuple of floats.
public static implicit operator Vector((float x, float y) t)
Parameters
Returns
implicit operator Vector(VectorInt)
public static implicit operator Vector(VectorInt v)
Parameters
vVectorIntThe integer vector to convert.
Returns
operator !=(Vector, Vector)
Determines whether two Vector instances are not equal.
public static bool operator !=(Vector v1, Vector v2)
Parameters
Returns
- bool
true if the vectors are not equal; otherwise, false.
operator *(float, Vector)
Multiplies a scalar by a vector.
public static Vector operator *(float f, Vector v)
Parameters
Returns
- Vector
The scaled vector.
operator *(Vector, float)
Multiplies a vector by a scalar.
public static Vector operator *(Vector v, float f)
Parameters
Returns
- Vector
The scaled vector.
operator -(Vector, Vector)
Subtracts one vector from another.
public static Vector operator -(Vector v1, Vector v2)
Parameters
Returns
- Vector
The difference as a vector.
operator -(Vector)
Negates a vector.
public static Vector operator -(Vector v)
Parameters
vVectorThe vector to negate.
Returns
- Vector
The negated vector.