Struct Vec2
- Namespace
- TDMaker.Core
- Assembly
- TDMaker.Core.dll
A simulation-space vector independent of any engine.
public readonly struct Vec2 : IEquatable<Vec2>
- Implements
- Inherited Members
Constructors
Vec2(float, float)
Creates a vector.
public Vec2(float x, float y)
Parameters
Fields
X
The horizontal coordinate.
public readonly float X
Field Value
Y
The vertical coordinate.
public readonly float Y
Field Value
Properties
Length
The Euclidean length.
public float Length { get; }
Property Value
LengthSquared
The squared Euclidean length.
public float LengthSquared { get; }
Property Value
Normalized
Returns a unit vector, or zero for a zero vector.
public Vec2 Normalized { get; }
Property Value
Zero
The origin.
public static Vec2 Zero { get; }
Property Value
Methods
DistanceSquared(Vec2, Vec2, float)
Measures squared distance using a vertical range multiplier.
public static float DistanceSquared(Vec2 a, Vec2 b, float yScale = 1)
Parameters
Returns
Equals(object)
Compares coordinates exactly.
public override bool Equals(object obj)
Parameters
objobject
Returns
Equals(Vec2)
Compares coordinates exactly.
public bool Equals(Vec2 other)
Parameters
otherVec2
Returns
GetHashCode()
Returns a coordinate hash.
public override int GetHashCode()
Returns
Lerp(Vec2, Vec2, float)
Interpolates between two positions.
public static Vec2 Lerp(Vec2 a, Vec2 b, float t)
Parameters
Returns
MoveTowards(Vec2, Vec2, float)
Moves towards a destination without overshooting it.
public static Vec2 MoveTowards(Vec2 from, Vec2 to, float distance)
Parameters
Returns
ToString()
Formats the vector for diagnostics.
public override string ToString()
Returns
Operators
operator +(Vec2, Vec2)
Adds two vectors.
public static Vec2 operator +(Vec2 a, Vec2 b)
Parameters
Returns
operator /(Vec2, float)
Divides a vector by a scalar.
public static Vec2 operator /(Vec2 a, float s)
Parameters
Returns
operator *(Vec2, float)
Scales a vector.
public static Vec2 operator *(Vec2 a, float s)
Parameters
Returns
operator -(Vec2, Vec2)
Subtracts two vectors.
public static Vec2 operator -(Vec2 a, Vec2 b)