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

3D Vector class

Classes

struct  StackArray8Vec3
 

Public Member Functions

 Vec3 (float x=0f, float y=0f, float z=0f, float w=-1f)
 Initializes a new instance of the Vec3 struct.
 
 Vec3 (Vec3 c, float w=-1)
 Initializes a new instance of the Vec3 struct.
 
 Vec3 (Vec2 xy, float z=0f, float w=-1f)
 Initializes a new instance of the Vec3 struct.
 
 Vec3 (Vector3 vector3)
 
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. This value changes when one of the X, Y, or Z values changes. Therefore, do not put Vec3 objects to a Hash table. If you have to, then do not change any of the values of the object after it is put to a Hash table.
 
Vec3 NormalizedCopy ()
 
float Normalize ()
 Normalizes current vector.
 
Vec3 ClampedCopy (float min, float max)
 
Vec3 ClampedCopy (float min, float max, out bool valueClamped)
 
void NormalizeWithoutChangingZ ()
 Normalizes current vector without changing Z component.
 
bool NearlyEquals (Vec3 v, float epsilon=MBMath.Epsilon)
 Checks if vector is nearly equals to another vector.
 
void RotateAboutX (float a)
 Rotates the vector about X axis.
 
void RotateAboutY (float a)
 Rotates the vector about Y axis.
 
void RotateAboutZ (float a)
 Rotates the vector about Z axis.
 
Vec3 RotateAboutAnArbitraryVector (Vec3 vec, float a)
 Rotates the vector about param vector.
 
Vec3 Reflect (Vec3 normal)
 
Vec3 ProjectOnUnitVector (Vec3 ov)
 
float DistanceSquared (Vec3 v)
 Square of the length of distance from v.
 
float Distance (Vec3 v)
 The length of distance from v.
 
override string ToString ()
 Creates readable string representation.
 

Static Public Member Functions

static Vec3 Abs (Vec3 vec)
 
static operator Vector3 (Vec3 vec3)
 
static float DotProduct (Vec3 v1, Vec3 v2)
 Dot product of two vectors.
 
static Vec3 Lerp (Vec3 v1, Vec3 v2, float alpha)
 
static Vec3 Slerp (Vec3 start, Vec3 end, float percent)
 
static Vec3 Vec3Max (Vec3 v1, Vec3 v2)
 Returns maximum of each component of two vectors.
 
static Vec3 Vec3Min (Vec3 v1, Vec3 v2)
 Returns minimum of each component of two vectors.
 
static Vec3 CrossProduct (Vec3 va, Vec3 vb)
 Cross product of two vectors.
 
static Vec3 operator- (Vec3 v)
 Implements the operator -.
 
static Vec3 operator+ (Vec3 v1, Vec3 v2)
 Implements the operator +.
 
static Vec3 operator- (Vec3 v1, Vec3 v2)
 Implements the operator -.
 
static Vec3 operator* (Vec3 v, float f)
 Implements scalar to vector product.
 
static Vec3 operator* (float f, Vec3 v)
 
static Vec3 operator* (Vec3 v, MatrixFrame frame)
 
static Vec3 operator/ (Vec3 v, float f)
 Implements vector and float division. Internally, the division is converted to a multiplication for performance reasons.
 
static bool operator== (Vec3 v1, Vec3 v2)
 Implements the operator ==.
 
static bool operator!= (Vec3 v1, Vec3 v2)
 Implements the operator !=.
 
static float AngleBetweenTwoVectors (Vec3 v1, Vec3 v2)
 
static Vec3 Parse (string input)
 

Public Attributes

float x
 X component of the vector.
 
float y
 Y component of the vector.
 
float z
 Z component of the vector.
 
float w
 W component of the vector.
 

Static Public Attributes

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

Properties

float X [get]
 
float Y [get]
 
float Z [get]
 
float this[int i] [get, set]
 Gets or sets the vector value with the specified index.
 
float Length [get]
 Calculates and returns the length of the vector.
 
float LengthSquared [get]
 Calculates and returns the square of the length of the vector.
 
bool IsValid [get]
 Determines if all (XYZ) components are valid (not NaN or Infinite) or not.
 
bool IsValidXYZW [get]
 Determines if all (XYZW) components are valid (not NaN or Infinite) or not.
 
bool IsUnit [get]
 Determines whether vector is unit. <c>true</c> if vector is unit; otherwise, <c>false</c>.
 
bool IsNonZero [get]
 Determines whether if vector is non zero. <c>true</c> if vector is non zero; otherwise, <c>false</c>.
 
Vec2 AsVec2 [get, set]
 Returns new Vec2 from X,Y components, discards Z.
 
uint ToARGB [get]
 
float RotationZ [get]
 Rotation angle about the up/z-axis. Yaw rotation value. Value is in radians.
 
float RotationX [get]
 Rotation angle about the side/x-axis. Pitch rotation value. Value is in radians.
 

Constructor & Destructor Documentation

◆ Vec3() [1/4]

TaleWorlds.Library.Vec3.Vec3 ( float  x = 0f,
float  y = 0f,
float  z = 0f,
float  w = -1f 
)
Parameters
xX value.
yY value.
zZ value.
wW value.

◆ Vec3() [2/4]

TaleWorlds.Library.Vec3.Vec3 ( Vec3  c,
float  w = -1 
)
Parameters
cThe vector that the values are copied from.
wW value.

◆ Vec3() [3/4]

TaleWorlds.Library.Vec3.Vec3 ( Vec2  xy,
float  z = 0f,
float  w = -1f 
)
Parameters
xyThe vector that the values are copied from.
zZ value.
wW value.

◆ Vec3() [4/4]

TaleWorlds.Library.Vec3.Vec3 ( Vector3  vector3)

Member Function Documentation

◆ Abs()

static Vec3 TaleWorlds.Library.Vec3.Abs ( Vec3  vec)
static

◆ operator Vector3()

static TaleWorlds.Library.Vec3.operator Vector3 ( Vec3  vec3)
explicitstatic

◆ DotProduct()

static float TaleWorlds.Library.Vec3.DotProduct ( Vec3  v1,
Vec3  v2 
)
static
Parameters
v1First vector
v2Second vector
Returns
Dot product

◆ Lerp()

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

◆ Slerp()

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

◆ Vec3Max()

static Vec3 TaleWorlds.Library.Vec3.Vec3Max ( Vec3  v1,
Vec3  v2 
)
static
Parameters
v1First vector
v2Second vector
Returns
Elementvise maximum of two vectors

◆ Vec3Min()

static Vec3 TaleWorlds.Library.Vec3.Vec3Min ( Vec3  v1,
Vec3  v2 
)
static
Parameters
v1First vector
v2Second vector
Returns
Element vise minimum of two vectors

◆ CrossProduct()

static Vec3 TaleWorlds.Library.Vec3.CrossProduct ( Vec3  va,
Vec3  vb 
)
static
Parameters
vaFirst vector
vbSecond vector
Returns
Cross product

◆ operator-() [1/2]

static Vec3 TaleWorlds.Library.Vec3.operator- ( Vec3  v)
static
Parameters
vThe v.
Returns
Negative of vector

◆ operator+()

static Vec3 TaleWorlds.Library.Vec3.operator+ ( Vec3  v1,
Vec3  v2 
)
static
Parameters
v1The v1.
v2The v2.
Returns
Summation of vectors.

◆ operator-() [2/2]

static Vec3 TaleWorlds.Library.Vec3.operator- ( Vec3  v1,
Vec3  v2 
)
static
Parameters
v1The v1.
v2The v2.
Returns
Difference of vectors

◆ operator*() [1/3]

static Vec3 TaleWorlds.Library.Vec3.operator* ( Vec3  v,
float  f 
)
static
Parameters
vThe v.
fThe f.
Returns
The result of the operator.

◆ operator*() [2/3]

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

◆ operator*() [3/3]

static Vec3 TaleWorlds.Library.Vec3.operator* ( Vec3  v,
MatrixFrame  frame 
)
static

◆ operator/()

static Vec3 TaleWorlds.Library.Vec3.operator/ ( Vec3  v,
float  f 
)
static
Parameters
vThe v.
fThe f.
Returns
The result of the operator.

◆ operator==()

static bool TaleWorlds.Library.Vec3.operator== ( Vec3  v1,
Vec3  v2 
)
static
Parameters
v1The v1.
v2The v2.
Returns
The result of the operator.

◆ operator!=()

static bool TaleWorlds.Library.Vec3.operator!= ( Vec3  v1,
Vec3  v2 
)
static
Parameters
v1The v1.
v2The v2.
Returns
The result of the operator.

◆ Equals()

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

◆ GetHashCode()

override int TaleWorlds.Library.Vec3.GetHashCode ( )
Returns
A hash code for this instance.

◆ NormalizedCopy()

Vec3 TaleWorlds.Library.Vec3.NormalizedCopy ( )

◆ Normalize()

float TaleWorlds.Library.Vec3.Normalize ( )
Returns
Length of the vector before normalization

◆ ClampedCopy() [1/2]

Vec3 TaleWorlds.Library.Vec3.ClampedCopy ( float  min,
float  max 
)

◆ ClampedCopy() [2/2]

Vec3 TaleWorlds.Library.Vec3.ClampedCopy ( float  min,
float  max,
out bool  valueClamped 
)

◆ NormalizeWithoutChangingZ()

void TaleWorlds.Library.Vec3.NormalizeWithoutChangingZ ( )

◆ NearlyEquals()

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

◆ RotateAboutX()

void TaleWorlds.Library.Vec3.RotateAboutX ( float  a)
Parameters
aRotation angle in radians.

◆ RotateAboutY()

void TaleWorlds.Library.Vec3.RotateAboutY ( float  a)
Parameters
aRotation angle in radians

◆ RotateAboutZ()

void TaleWorlds.Library.Vec3.RotateAboutZ ( float  a)
Parameters
aRotation angle in radians

◆ RotateAboutAnArbitraryVector()

Vec3 TaleWorlds.Library.Vec3.RotateAboutAnArbitraryVector ( Vec3  vec,
float  a 
)
Parameters
vecRotation axis
aRotation angle in radians

◆ Reflect()

Vec3 TaleWorlds.Library.Vec3.Reflect ( Vec3  normal)

◆ ProjectOnUnitVector()

Vec3 TaleWorlds.Library.Vec3.ProjectOnUnitVector ( Vec3  ov)

◆ DistanceSquared()

float TaleWorlds.Library.Vec3.DistanceSquared ( Vec3  v)
Parameters
vVector v.
Returns
Length square of difference.

◆ Distance()

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

◆ AngleBetweenTwoVectors()

static float TaleWorlds.Library.Vec3.AngleBetweenTwoVectors ( Vec3  v1,
Vec3  v2 
)
static

◆ ToString()

override string TaleWorlds.Library.Vec3.ToString ( )
Returns
Output string

◆ Parse()

static Vec3 TaleWorlds.Library.Vec3.Parse ( string  input)
static

Member Data Documentation

◆ x

float TaleWorlds.Library.Vec3.x

◆ y

float TaleWorlds.Library.Vec3.y

◆ z

float TaleWorlds.Library.Vec3.z

◆ w

float TaleWorlds.Library.Vec3.w

◆ Side

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

◆ Forward

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

◆ Up

readonly Vec3 TaleWorlds.Library.Vec3.Up = new Vec3(0, 0, 1)
static

◆ One

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

◆ Zero

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

◆ Invalid

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

Property Documentation

◆ X

float TaleWorlds.Library.Vec3.X
get

◆ Y

float TaleWorlds.Library.Vec3.Y
get

◆ Z

float TaleWorlds.Library.Vec3.Z
get

◆ this[int i]

float TaleWorlds.Library.Vec3.this[int i]
getset
Parameters
iIndex of the requested value.
Returns
X if i = 0, Y if i = 1 and Z if i = 2.

◆ Length

float TaleWorlds.Library.Vec3.Length
get

◆ LengthSquared

float TaleWorlds.Library.Vec3.LengthSquared
get

◆ IsValid

bool TaleWorlds.Library.Vec3.IsValid
get

◆ IsValidXYZW

bool TaleWorlds.Library.Vec3.IsValidXYZW
get

◆ IsUnit

bool TaleWorlds.Library.Vec3.IsUnit
get

◆ IsNonZero

bool TaleWorlds.Library.Vec3.IsNonZero
get

◆ AsVec2

Vec2 TaleWorlds.Library.Vec3.AsVec2
getset

◆ ToARGB

uint TaleWorlds.Library.Vec3.ToARGB
get

◆ RotationZ

float TaleWorlds.Library.Vec3.RotationZ
get

◆ RotationX

float TaleWorlds.Library.Vec3.RotationX
get