Struct Vec2

Namespace
SurvivorsMaker.Simulation
Assembly
SurvivorsMaker.Simulation.dll

2D vector for the simulation, with engine-independent arithmetic. Presentation converts to Vector2.

public struct Vec2 : IEquatable<Vec2>
Implements
Inherited Members

Constructors

Vec2(float, float)

public Vec2(float x, float y)

Parameters

x float
y float

Fields

Right

public static readonly Vec2 Right

Field Value

Vec2

Up

public static readonly Vec2 Up

Field Value

Vec2

X

public float X

Field Value

float

Y

public float Y

Field Value

float

Zero

public static readonly Vec2 Zero

Field Value

Vec2

Properties

Angle

Angle from +X in radians, −π..π.

public float Angle { get; }

Property Value

float

Length

public float Length { get; }

Property Value

float

LengthSquared

public float LengthSquared { get; }

Property Value

float

Normalized

Unit vector in the same direction, or zero for a zero vector.

public Vec2 Normalized { get; }

Property Value

Vec2

Methods

ClampLength(float)

Same direction, length at most max.

public Vec2 ClampLength(float max)

Parameters

max float

Returns

Vec2

Distance(Vec2, Vec2)

public static float Distance(Vec2 a, Vec2 b)

Parameters

a Vec2
b Vec2

Returns

float

DistanceSquared(Vec2, Vec2)

public static float DistanceSquared(Vec2 a, Vec2 b)

Parameters

a Vec2
b Vec2

Returns

float

Dot(Vec2, Vec2)

public static float Dot(Vec2 a, Vec2 b)

Parameters

a Vec2
b Vec2

Returns

float

Equals(Vec2)

public bool Equals(Vec2 other)

Parameters

other Vec2

Returns

bool

Equals(object)

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

FromAngle(float, float)

public static Vec2 FromAngle(float radians, float length = 1)

Parameters

radians float
length float

Returns

Vec2

GetHashCode()

public override int GetHashCode()

Returns

int

Lerp(Vec2, Vec2, float)

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

Parameters

a Vec2
b Vec2
t float

Returns

Vec2

MoveTowards(Vec2, Vec2, float)

Moves toward a target by at most maxStep without overshooting.

public static Vec2 MoveTowards(Vec2 from, Vec2 to, float maxStep)

Parameters

from Vec2
to Vec2
maxStep float

Returns

Vec2

Rotated(float)

public Vec2 Rotated(float radians)

Parameters

radians float

Returns

Vec2

ToString()

public override string ToString()

Returns

string

Operators

operator +(Vec2, Vec2)

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

Parameters

a Vec2
b Vec2

Returns

Vec2

operator /(Vec2, float)

public static Vec2 operator /(Vec2 a, float s)

Parameters

a Vec2
s float

Returns

Vec2

operator ==(Vec2, Vec2)

public static bool operator ==(Vec2 a, Vec2 b)

Parameters

a Vec2
b Vec2

Returns

bool

operator !=(Vec2, Vec2)

public static bool operator !=(Vec2 a, Vec2 b)

Parameters

a Vec2
b Vec2

Returns

bool

operator *(Vec2, float)

public static Vec2 operator *(Vec2 a, float s)

Parameters

a Vec2
s float

Returns

Vec2

operator *(float, Vec2)

public static Vec2 operator *(float s, Vec2 a)

Parameters

s float
a Vec2

Returns

Vec2

operator -(Vec2, Vec2)

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

Parameters

a Vec2
b Vec2

Returns

Vec2

operator -(Vec2)

public static Vec2 operator -(Vec2 a)

Parameters

a Vec2

Returns

Vec2