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
Fields
x
X component of the vector.
public float x
Field Value
y
Y component of the vector.
public float y
Field Value
Properties
magnitude
The magnitude of the vector.
public float magnitude { get; }
Property Value
magnitudeSqr
The magnitude of the vector squared.
public float magnitudeSqr { get; }
Property Value
Methods
Cross(Vector2, Vector2)
Cross product of two vectors.
public static float Cross(Vector2 a, Vector2 b)
Parameters
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
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
Returns
Lerp(Vector2, Vector2, float)
Linearly interpolates between two vectors.
public static Vector2 Lerp(Vector2 a, Vector2 b, float t)
Parameters
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
currentVector2Current value.
targetVector2Target value.
currentVelocityVector2Current velocity, modified by the function.
smoothTimefloatApproximate time to reach the target.
maxSpeedfloatMaximum speed allowed.
deltaTimefloatTime 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
Returns
operator /(Vector2, float)
Divides a vector by a scalar.
public static Vector2 operator /(Vector2 a, float b)
Parameters
Returns
operator *(Vector2, Vector2)
Dot product of two vectors.
public static float operator *(Vector2 a, Vector2 b)
Parameters
Returns
operator *(Vector2, float)
Multiplies a vector by a scalar.
public static Vector2 operator *(Vector2 a, float b)
Parameters
Returns
operator *(float, Vector2)
Multiplies a vector by a scalar.
public static Vector2 operator *(float a, Vector2 b)
Parameters
Returns
operator -(Vector2, Vector2)
Subtracts two vectors component-wise.
public static Vector2 operator -(Vector2 a, Vector2 b)