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
Fields
Right
public static readonly Vec2 Right
Field Value
Up
public static readonly Vec2 Up
Field Value
X
public float X
Field Value
Y
public float Y
Field Value
Zero
public static readonly Vec2 Zero
Field Value
Properties
Angle
Angle from +X in radians, −π..π.
public float Angle { get; }
Property Value
Length
public float Length { get; }
Property Value
LengthSquared
public float LengthSquared { get; }
Property Value
Normalized
Unit vector in the same direction, or zero for a zero vector.
public Vec2 Normalized { get; }
Property Value
Methods
ClampLength(float)
Same direction, length at most max.
public Vec2 ClampLength(float max)
Parameters
maxfloat
Returns
Distance(Vec2, Vec2)
public static float Distance(Vec2 a, Vec2 b)
Parameters
Returns
DistanceSquared(Vec2, Vec2)
public static float DistanceSquared(Vec2 a, Vec2 b)
Parameters
Returns
Dot(Vec2, Vec2)
public static float Dot(Vec2 a, Vec2 b)
Parameters
Returns
Equals(Vec2)
public bool Equals(Vec2 other)
Parameters
otherVec2
Returns
Equals(object)
public override bool Equals(object obj)
Parameters
objobject
Returns
FromAngle(float, float)
public static Vec2 FromAngle(float radians, float length = 1)
Parameters
Returns
GetHashCode()
public override int GetHashCode()
Returns
Lerp(Vec2, Vec2, float)
public static Vec2 Lerp(Vec2 a, Vec2 b, float t)
Parameters
Returns
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
Returns
Rotated(float)
public Vec2 Rotated(float radians)
Parameters
radiansfloat
Returns
ToString()
public override string ToString()
Returns
Operators
operator +(Vec2, Vec2)
public static Vec2 operator +(Vec2 a, Vec2 b)
Parameters
Returns
operator /(Vec2, float)
public static Vec2 operator /(Vec2 a, float s)
Parameters
Returns
operator ==(Vec2, Vec2)
public static bool operator ==(Vec2 a, Vec2 b)
Parameters
Returns
operator !=(Vec2, Vec2)
public static bool operator !=(Vec2 a, Vec2 b)
Parameters
Returns
operator *(Vec2, float)
public static Vec2 operator *(Vec2 a, float s)
Parameters
Returns
operator *(float, Vec2)
public static Vec2 operator *(float s, Vec2 a)
Parameters
Returns
operator -(Vec2, Vec2)
public static Vec2 operator -(Vec2 a, Vec2 b)
Parameters
Returns
operator -(Vec2)
public static Vec2 operator -(Vec2 a)
Parameters
aVec2