Table of Contents

Struct Vector

Namespace
Termule.Engine.Types
Assembly
Termule.Engine.dll

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

X float

The X component of the vector.

Y float

The Y component of the vector.

Properties

Magnitude

Gets the magnitude (length) of the vector.

public float Magnitude { get; }

Property Value

float

Normalized

Gets the normalized (unit-length) vector.

public Vector Normalized { get; }

Property Value

Vector

X

Gets the X component of the vector.

public float X { get; }

Property Value

float

Y

Gets the y component of the vector.

public float Y { get; }

Property Value

float

Methods

CeilToInt()

Applies ceiling to this vector's components, returning a VectorInt.

public VectorInt CeilToInt()

Returns

VectorInt

The resulting VectorInt.

Equals(object)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and 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

VectorInt

The resulting VectorInt.

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

VectorInt

The rounded VectorInt.

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

v1 Vector

The first vector.

v2 Vector

The second vector.

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

v Vector

The vector to divide.

f float

The scalar divisor.

Returns

Vector

The resulting vector.

operator ==(Vector, Vector)

Determines whether two Vector instances are equal.

public static bool operator ==(Vector v1, Vector v2)

Parameters

v1 Vector

The first Vector to compare.

v2 Vector

The second Vector to compare.

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

t (float x, float y)

The component values to use.

Returns

Vector

implicit operator Vector(VectorInt)

Creates a Vector from a VectorInt.

public static implicit operator Vector(VectorInt v)

Parameters

v VectorInt

The integer vector to convert.

Returns

Vector

operator !=(Vector, Vector)

Determines whether two Vector instances are not equal.

public static bool operator !=(Vector v1, Vector v2)

Parameters

v1 Vector

The first Vector to compare.

v2 Vector

The second Vector to compare.

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

f float

The scalar multiplier.

v Vector

The vector to scale.

Returns

Vector

The scaled vector.

operator *(Vector, float)

Multiplies a vector by a scalar.

public static Vector operator *(Vector v, float f)

Parameters

v Vector

The vector to scale.

f float

The scalar multiplier.

Returns

Vector

The scaled vector.

operator -(Vector, Vector)

Subtracts one vector from another.

public static Vector operator -(Vector v1, Vector v2)

Parameters

v1 Vector

The first vector.

v2 Vector

The second vector.

Returns

Vector

The difference as a vector.

operator -(Vector)

Negates a vector.

public static Vector operator -(Vector v)

Parameters

v Vector

The vector to negate.

Returns

Vector

The negated vector.