M&B: Bannerlord 1.2.12
The horns sound, the ravens gather.
Loading...
Searching...
No Matches
TaleWorlds.Library.Vec2 Struct Reference

2D vector class

Classes

struct  StackArray6Vec2
 

Public Member Functions

 Vec2 (float a, float b)
 Initializes a new instance of vector.
 
 Vec2 (Vec2 v)
 Initializes a new instance of vector.
 
 Vec2 (Vector2 v)
 
Vec3 ToVec3 (float z=0.0f)
 
float Normalize ()
 Normalizes vector.
 
Vec2 Normalized ()
 
override bool Equals (object obj)
 Determines whether the specified generic object is equal to this instance.
 
override int GetHashCode ()
 Returns a hash code for this instance.
 
bool IsUnit ()
 
bool IsNonZero ()
 
bool NearlyEquals (Vec2 v, float epsilon=MBMath.Epsilon)
 Checks if vector is nearly equals to another vector.
 
void RotateCCW (float angleInRadians)
 Rotates the vector in Counter-Clockwise direction by an angle.
 
float DotProduct (Vec2 v)
 Dot product of two vectors.
 
Vec2 TransformToLocalUnitF (Vec2 a)
 Transforms a vector to local. assumes vec is unit f vector.
 
Vec2 TransformToParentUnitF (Vec2 a)
 Transforms a vector to parent. assumes vec is unit f vector.
 
Vec2 TransformToLocalUnitFLeftHanded (Vec2 a)
 Transforms a vector to local. Uses left handed coordinate system. assumes vec is unit f vector.
 
Vec2 TransformToParentUnitFLeftHanded (Vec2 a)
 Transforms a vector to parent. Uses left handed coordinate system. assumes vec is unit f vector.
 
Vec2 RightVec ()
 90 degrees rotated vector
 
Vec2 LeftVec ()
 -90 degrees rotated vector
 
override string ToString ()
 
float DistanceSquared (Vec2 v)
 
float Distance (Vec2 v)
 The length of distance from v.
 
float DistanceToLineSegment (Vec2 v, Vec2 w, out Vec2 closestPointOnLineSegment)
 
float DistanceSquaredToLineSegment (Vec2 v, Vec2 w, out Vec2 closestPointOnLineSegment)
 
float AngleBetween (Vec2 vector2)
 Returns the the angle in radians between this and the argument vectors.
 

Static Public Member Functions

static operator Vector2 (Vec2 vec2)
 
static implicit operator Vec2 (Vector2 vec2)
 
static WindingOrder GetWindingOrder (Vec2 first, Vec2 second, Vec2 third)
 
static float CCW (Vec2 va, Vec2 vb)
 Counter-clockwise: 2-d version of cross product. Check sign of result. = |va|*|vb|*sin(counter-clockwise angle)
 
static bool operator== (Vec2 v1, Vec2 v2)
 
static bool operator!= (Vec2 v1, Vec2 v2)
 
static Vec2 operator- (Vec2 v)
 
static Vec2 operator+ (Vec2 v1, Vec2 v2)
 
static Vec2 operator- (Vec2 v1, Vec2 v2)
 
static Vec2 operator* (Vec2 v, float f)
 
static Vec2 operator* (float f, Vec2 v)
 
static Vec2 operator/ (float f, Vec2 v)
 
static Vec2 operator/ (Vec2 v, float f)
 
static float DotProduct (Vec2 va, Vec2 vb)
 Dot product of two vectors.
 
static Vec2 FromRotation (float rotation)
 Creates a new Vec2 from the rotation angle.
 
static Vec2 Max (Vec2 v1, Vec2 v2)
 Returns maximum of each component of two vectors.
 
static Vec2 Max (Vec2 v1, float f)
 
static Vec2 Min (Vec2 v1, Vec2 v2)
 Returns minimum of each component of two vectors.
 
static Vec2 Min (Vec2 v1, float f)
 
static float DistanceToLine (Vec2 line1, Vec2 line2, Vec2 point)
 
static float DistanceToLineSegmentSquared (Vec2 line1, Vec2 line2, Vec2 point)
 
static Vec2 Lerp (Vec2 v1, Vec2 v2, float alpha)
 
static Vec2 Slerp (Vec2 start, Vec2 end, float percent)
 
static int SideOfLine (Vec2 point, Vec2 line1, Vec2 line2)
 

Public Attributes

float x
 x component of the vector.
 
float y
 y component of the vector.
 

Static Public Attributes

static readonly Vec2 Side = new Vec2(1, 0)
 
static readonly Vec2 Forward = new Vec2(0, 1)
 
static readonly Vec2 One = new Vec2(1, 1)
 
static readonly Vec2 Zero = new Vec2(0, 0)
 
static readonly Vec2 Invalid = new Vec2(float.NaN, float.NaN)
 

Properties

float X [get]
 
float Y [get]
 
float this[int i] [get, set]
 Implements indexer operation.
 
float Length [get]
 Return the length of the vector.
 
float LengthSquared [get]
 Return the square of the length of the vector.
 
float RotationInRadians [get]
 Calculates the counter clockwise rotation from y axis in radians.
 
bool IsValid [get]
 Determines if all (XY) components are valid (not NaN or Infinite) or not.
 

Constructor & Destructor Documentation

◆ Vec2() [1/3]

TaleWorlds.Library.Vec2.Vec2 ( float a,
float b )
Parameters
ax value.
by value.

◆ Vec2() [2/3]

TaleWorlds.Library.Vec2.Vec2 ( Vec2 v)
Parameters
vCopied vector

◆ Vec2() [3/3]

TaleWorlds.Library.Vec2.Vec2 ( Vector2 v)

Member Function Documentation

◆ ToVec3()

Vec3 TaleWorlds.Library.Vec2.ToVec3 ( float z = 0::0f)

◆ operator Vector2()

static TaleWorlds.Library.Vec2.operator Vector2 ( Vec2 vec2)
explicitstatic

◆ operator Vec2()

static implicit TaleWorlds.Library.Vec2.operator Vec2 ( Vector2 vec2)
static

◆ Normalize()

float TaleWorlds.Library.Vec2.Normalize ( )
Returns
Length of vector.

◆ Normalized()

Vec2 TaleWorlds.Library.Vec2.Normalized ( )

◆ GetWindingOrder()

static WindingOrder TaleWorlds.Library.Vec2.GetWindingOrder ( Vec2 first,
Vec2 second,
Vec2 third )
static

◆ CCW()

static float TaleWorlds.Library.Vec2.CCW ( Vec2 va,
Vec2 vb )
static
Parameters
vaThe va.
vbThe vb.
Returns
|va|*|vb|*sin(counter-clockwise angle)

◆ Equals()

override bool TaleWorlds.Library.Vec2.Equals ( object obj)
Parameters
objThe generic object to compare with this instance.
Returns
true if the specified object is equal to this instance; otherwise, false.

◆ GetHashCode()

override int TaleWorlds.Library.Vec2.GetHashCode ( )
Returns
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

◆ operator==()

static bool TaleWorlds.Library.Vec2.operator== ( Vec2 v1,
Vec2 v2 )
static

◆ operator!=()

static bool TaleWorlds.Library.Vec2.operator!= ( Vec2 v1,
Vec2 v2 )
static

◆ operator-() [1/2]

static Vec2 TaleWorlds.Library.Vec2.operator- ( Vec2 v)
static

◆ operator+()

static Vec2 TaleWorlds.Library.Vec2.operator+ ( Vec2 v1,
Vec2 v2 )
static

◆ operator-() [2/2]

static Vec2 TaleWorlds.Library.Vec2.operator- ( Vec2 v1,
Vec2 v2 )
static

◆ operator*() [1/2]

static Vec2 TaleWorlds.Library.Vec2.operator* ( Vec2 v,
float f )
static

◆ operator*() [2/2]

static Vec2 TaleWorlds.Library.Vec2.operator* ( float f,
Vec2 v )
static

◆ operator/() [1/2]

static Vec2 TaleWorlds.Library.Vec2.operator/ ( float f,
Vec2 v )
static

◆ operator/() [2/2]

static Vec2 TaleWorlds.Library.Vec2.operator/ ( Vec2 v,
float f )
static

◆ IsUnit()

bool TaleWorlds.Library.Vec2.IsUnit ( )

◆ IsNonZero()

bool TaleWorlds.Library.Vec2.IsNonZero ( )

◆ NearlyEquals()

bool TaleWorlds.Library.Vec2.NearlyEquals ( Vec2 v,
float epsilon = MBMath::Epsilon )
Parameters
vVector that is compared.
epsilonEpsilon for equality.
Returns
true is nearly equals

◆ RotateCCW()

void TaleWorlds.Library.Vec2.RotateCCW ( float angleInRadians)
Parameters
angleInRadiansThe angle

◆ DotProduct() [1/2]

float TaleWorlds.Library.Vec2.DotProduct ( Vec2 v)
Parameters
vSecond vector
Returns
Dot product

◆ DotProduct() [2/2]

static float TaleWorlds.Library.Vec2.DotProduct ( Vec2 va,
Vec2 vb )
static
Parameters
vaFirst vector
vbSecond vector
Returns
Dot product

◆ FromRotation()

static Vec2 TaleWorlds.Library.Vec2.FromRotation ( float rotation)
static
Parameters
rotation
Returns

◆ TransformToLocalUnitF()

Vec2 TaleWorlds.Library.Vec2.TransformToLocalUnitF ( Vec2 a)
Parameters
aVector to be transformed.
Returns
Transformed vector.

◆ TransformToParentUnitF()

Vec2 TaleWorlds.Library.Vec2.TransformToParentUnitF ( Vec2 a)
Parameters
aVector to be transformed.
Returns
Transformed vector.

◆ TransformToLocalUnitFLeftHanded()

Vec2 TaleWorlds.Library.Vec2.TransformToLocalUnitFLeftHanded ( Vec2 a)
Parameters
aVector to be transformed.
Returns
Transformed vector.

◆ TransformToParentUnitFLeftHanded()

Vec2 TaleWorlds.Library.Vec2.TransformToParentUnitFLeftHanded ( Vec2 a)
Parameters
aVector to be transformed.
Returns
Transformed vector.

◆ RightVec()

Vec2 TaleWorlds.Library.Vec2.RightVec ( )
Returns

◆ LeftVec()

Vec2 TaleWorlds.Library.Vec2.LeftVec ( )
Returns

◆ Max() [1/2]

static Vec2 TaleWorlds.Library.Vec2.Max ( Vec2 v1,
Vec2 v2 )
static
Parameters
vaFirst vector
vbSecond vector
Returns
Elementvise maximum of two vectors

◆ Max() [2/2]

static Vec2 TaleWorlds.Library.Vec2.Max ( Vec2 v1,
float f )
static

◆ Min() [1/2]

static Vec2 TaleWorlds.Library.Vec2.Min ( Vec2 v1,
Vec2 v2 )
static
Parameters
vaFirst vector
vbSecond vector
Returns
Element vise minimum of two vectors

◆ Min() [2/2]

static Vec2 TaleWorlds.Library.Vec2.Min ( Vec2 v1,
float f )
static

◆ ToString()

override string TaleWorlds.Library.Vec2.ToString ( )

◆ DistanceSquared()

float TaleWorlds.Library.Vec2.DistanceSquared ( Vec2 v)

◆ Distance()

float TaleWorlds.Library.Vec2.Distance ( Vec2 v)
Parameters
vVector v.
Returns
Length difference

◆ DistanceToLine()

static float TaleWorlds.Library.Vec2.DistanceToLine ( Vec2 line1,
Vec2 line2,
Vec2 point )
static

◆ DistanceToLineSegmentSquared()

static float TaleWorlds.Library.Vec2.DistanceToLineSegmentSquared ( Vec2 line1,
Vec2 line2,
Vec2 point )
static

◆ DistanceToLineSegment()

float TaleWorlds.Library.Vec2.DistanceToLineSegment ( Vec2 v,
Vec2 w,
out Vec2 closestPointOnLineSegment )

◆ DistanceSquaredToLineSegment()

float TaleWorlds.Library.Vec2.DistanceSquaredToLineSegment ( Vec2 v,
Vec2 w,
out Vec2 closestPointOnLineSegment )

◆ Lerp()

static Vec2 TaleWorlds.Library.Vec2.Lerp ( Vec2 v1,
Vec2 v2,
float alpha )
static

◆ Slerp()

static Vec2 TaleWorlds.Library.Vec2.Slerp ( Vec2 start,
Vec2 end,
float percent )
static

◆ AngleBetween()

float TaleWorlds.Library.Vec2.AngleBetween ( Vec2 vector2)
Parameters
vector2
Returns

◆ SideOfLine()

static int TaleWorlds.Library.Vec2.SideOfLine ( Vec2 point,
Vec2 line1,
Vec2 line2 )
static

Member Data Documentation

◆ x

float TaleWorlds.Library.Vec2.x

◆ y

float TaleWorlds.Library.Vec2.y

◆ Side

readonly Vec2 TaleWorlds.Library.Vec2.Side = new Vec2(1, 0)
static

◆ Forward

readonly Vec2 TaleWorlds.Library.Vec2.Forward = new Vec2(0, 1)
static

◆ One

readonly Vec2 TaleWorlds.Library.Vec2.One = new Vec2(1, 1)
static

◆ Zero

readonly Vec2 TaleWorlds.Library.Vec2.Zero = new Vec2(0, 0)
static

◆ Invalid

readonly Vec2 TaleWorlds.Library.Vec2.Invalid = new Vec2(float.NaN, float.NaN)
static

Property Documentation

◆ X

float TaleWorlds.Library.Vec2.X
get

◆ Y

float TaleWorlds.Library.Vec2.Y
get

◆ this[int i]

float TaleWorlds.Library.Vec2.this[int i]
getset

return x if i = 0 return y if i = 1

◆ Length

float TaleWorlds.Library.Vec2.Length
get
Returns
length of the vector

◆ LengthSquared

float TaleWorlds.Library.Vec2.LengthSquared
get
Returns
Square of length.

◆ RotationInRadians

float TaleWorlds.Library.Vec2.RotationInRadians
get

Rotation angle.

◆ IsValid

bool TaleWorlds.Library.Vec2.IsValid
get