Table of Contents

Struct Vector2

Namespace
BasilEngine.Mathematics
Assembly
BasilEngine.dll
[Disabled]
public struct Vector2
Inherited Members

Constructors

Vector2(float, float)

Create a vector with x and y.

public Vector2(float x, float y)

Parameters

x float

The x value

y float

The y value

Fields

x

X component of the vector.

public float x

Field Value

float

y

Y component of the vector.

public float y

Field Value

float

Properties

magnitude

The magnitude of the vector.

public float magnitude { get; }

Property Value

float

magnitudeSqr

The magnitude of the vector squared.

public float magnitudeSqr { get; }

Property Value

float

Methods

Cross(Vector2, Vector2)

Cross product of two vectors.

public static float Cross(Vector2 a, Vector2 b)

Parameters

a Vector2

LHS vector

b Vector2

RHS vector

Returns

float

A float value for 2d vector

Distance(Vector2, Vector2)

Get the distance between two vectors.

public static float Distance(Vector2 a, Vector2 b)

Parameters

a Vector2

The lhs vector

b Vector2

The rhs vector

Returns

float

The distane between the two vector.

Dot(Vector2, Vector2)

Dot product between two vectors.

public static float Dot(Vector2 a, Vector2 b)

Parameters

a Vector2
b Vector2

Returns

float

Lerp(Vector2, Vector2, float)

Linearly interpolates between two vectors.

public static Vector2 Lerp(Vector2 a, Vector2 b, float t)

Parameters

a Vector2

Start vector.

b Vector2

End vector.

t float

Interpolation factor.

Returns

Vector2

Interpolated vector.

Magnitude()

Magnitude of the vector.

public float Magnitude()

Returns

float

The magnitude

MagnitudeSqr()

Get the magnitude squared.

public float MagnitudeSqr()

Returns

float

Magnitude squared of the vector

Normalize()

Normalize the vector.

public Vector2 Normalize()

Returns

Vector2

Get the normalized vector

SmoothDamp(Vector2, Vector2, ref Vector2, float, float, float)

Gradually changes a vector towards a desired goal.

public static Vector2 SmoothDamp(Vector2 current, Vector2 target, ref Vector2 currentVelocity, float smoothTime, float maxSpeed, float deltaTime)

Parameters

current Vector2

Current value.

target Vector2

Target value.

currentVelocity Vector2

Current velocity, modified by the function.

smoothTime float

Approximate time to reach the target.

maxSpeed float

Maximum speed allowed.

deltaTime float

Time since last update.

Returns

Vector2

New vector after damping.

ToString()

Convert the vector to a string.

public override string ToString()

Returns

string

A string representaiton of the vector.

Operators

operator +(Vector2, Vector2)

Adds two vectors component-wise.

public static Vector2 operator +(Vector2 a, Vector2 b)

Parameters

a Vector2
b Vector2

Returns

Vector2

operator /(Vector2, float)

Divides a vector by a scalar.

public static Vector2 operator /(Vector2 a, float b)

Parameters

a Vector2
b float

Returns

Vector2

operator *(Vector2, Vector2)

Dot product of two vectors.

public static float operator *(Vector2 a, Vector2 b)

Parameters

a Vector2
b Vector2

Returns

float

operator *(Vector2, float)

Multiplies a vector by a scalar.

public static Vector2 operator *(Vector2 a, float b)

Parameters

a Vector2
b float

Returns

Vector2

operator *(float, Vector2)

Multiplies a vector by a scalar.

public static Vector2 operator *(float a, Vector2 b)

Parameters

a float
b Vector2

Returns

Vector2

operator -(Vector2, Vector2)

Subtracts two vectors component-wise.

public static Vector2 operator -(Vector2 a, Vector2 b)

Parameters

a Vector2
b Vector2

Returns

Vector2