BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
BrawlLib.Internal.Vector4 Struct Reference
Inheritance diagram for BrawlLib.Internal.Vector4:

Public Member Functions

 Vector4 (float x, float y, float z, float w)
 
 Vector4 (float s)
 
 Vector4 (SerializationInfo info, StreamingContext context)
 
void GetObjectData (SerializationInfo info, StreamingContext context)
 
float Length ()
 
float Dot ()
 
float Dot (Vector4 v)
 
Vector4 Normalize ()
 
float Dot3 ()
 
float Dot3 (Vector4 v)
 
float Length3 ()
 
Vector4 Normalize3 ()
 
override string ToString ()
 
override bool Equals (object obj)
 
override int GetHashCode ()
 
void ToAxisAngle (out Vector3 axis, out float angle)
 
Vector4 ToAxisAngle ()
 
Vector3 ToEuler ()
 

Static Public Member Functions

static operator Vector4 (Vector3 v)
 
static Vector4 operator* (Vector4 v, float f)
 
static Vector4 operator/ (Vector4 v, float f)
 
static Vector4 operator- (Vector4 v1, Vector4 v2)
 
static Vector4 operator+ (Vector4 v1, Vector4 v2)
 
static Vector4 operator* (Vector4 v1, Vector4 v2)
 
static bool operator== (Vector4 v1, Vector4 v2)
 
static bool operator!= (Vector4 v1, Vector4 v2)
 
static Vector4 FromAxisAngle (Vector3 axis, float angle)
 
static Vector4 FromEulerAngles (Vector3 v)
 

Public Attributes

float _x
 
float _y
 
float _z
 
float _w
 

Static Public Attributes

static readonly Vector4 UnitX = new Vector4(1, 0, 0, 0)
 
static readonly Vector4 UnitY = new Vector4(0, 1, 0, 0)
 
static readonly Vector4 UnitZ = new Vector4(0, 0, 1, 0)
 
static readonly Vector4 UnitW = new Vector4(0, 0, 0, 1)
 
static readonly Vector4 Zero = new Vector4(0, 0, 0, 0)
 
static readonly Vector4 One = new Vector4(1, 1, 1, 1)
 
static readonly Vector4 Identity = new Vector4(0, 0, 0, 1)
 

Properties

float this[int index] [get, set]
 
VoidPtr Address [get]
 

Constructor & Destructor Documentation

◆ Vector4() [1/3]

BrawlLib.Internal.Vector4.Vector4 ( float  x,
float  y,
float  z,
float  w 
)
inline
16 {
17 _x = x;
18 _y = y;
19 _z = z;
20 _w = w;
21 }
float _x
Definition: Vector4.cs:13
float _z
Definition: Vector4.cs:13
float _y
Definition: Vector4.cs:13
float _w
Definition: Vector4.cs:13

◆ Vector4() [2/3]

BrawlLib.Internal.Vector4.Vector4 ( float  s)
inline
24 {
25 _x = s;
26 _y = s;
27 _z = s;
28 _w = 1;
29 }

◆ Vector4() [3/3]

BrawlLib.Internal.Vector4.Vector4 ( SerializationInfo  info,
StreamingContext  context 
)
inline
32 {
33 _x = info.GetSingle("_x");
34 _z = info.GetSingle("_y");
35 _y = info.GetSingle("_z");
36 _w = info.GetSingle("_w");
37 }

Member Function Documentation

◆ Dot() [1/2]

float BrawlLib.Internal.Vector4.Dot ( )
inline
103 {
104 return _x * _x + _y * _y + _z * _z + _w * _w;
105 }

◆ Dot() [2/2]

float BrawlLib.Internal.Vector4.Dot ( Vector4  v)
inline
108 {
109 return _x * v._x + _y * v._y + _z * v._z + _w * v._w;
110 }

◆ Dot3() [1/2]

float BrawlLib.Internal.Vector4.Dot3 ( )
inline
118 {
119 return _x * _x + _y * _y + _z * _z;
120 }

◆ Dot3() [2/2]

float BrawlLib.Internal.Vector4.Dot3 ( Vector4  v)
inline
123 {
124 return _x * v._x + _y * v._y + _z * v._z;
125 }

◆ Equals()

override bool BrawlLib.Internal.Vector4.Equals ( object  obj)
inline
146 {
147 if (obj is Vector4 vector4)
148 {
149 return this == vector4;
150 }
151
152 return false;
153 }

◆ FromAxisAngle()

static Vector4 BrawlLib.Internal.Vector4.FromAxisAngle ( Vector3  axis,
float  angle 
)
inlinestatic
225 {
226 if (axis.Dot() == 0.0f)
227 {
228 return Identity;
229 }
230
231 Vector4 result = Identity;
232
233 angle *= 0.5f;
234 axis.Normalize();
235 result._x = axis._x * (float) Math.Sin(angle);
236 result._y = axis._y * (float) Math.Sin(angle);
237 result._z = axis._z * (float) Math.Sin(angle);
238 result._w = (float) Math.Cos(angle);
239
240 return result.Normalize();
241 }
Vector4(float x, float y, float z, float w)
Definition: Vector4.cs:15
static readonly Vector4 Identity
Definition: Vector4.cs:188
Vector4 Normalize()
Definition: Vector4.cs:112

◆ FromEulerAngles()

static Vector4 BrawlLib.Internal.Vector4.FromEulerAngles ( Vector3  v)
inlinestatic
244 {
245 Vector3
246 vx = new Vector3(1, 0, 0),
247 vy = new Vector3(0, 1, 0),
248 vz = new Vector3(0, 0, 1);
249 Vector4 qx, qy, qz;
250
251 qx = FromAxisAngle(vx, v._x);
252 qy = FromAxisAngle(vy, v._y);
253 qz = FromAxisAngle(vz, v._z);
254
255 return qx * qy * qz;
256 }
static Vector4 FromAxisAngle(Vector3 axis, float angle)
Definition: Vector4.cs:224

◆ GetHashCode()

override int BrawlLib.Internal.Vector4.GetHashCode ( )
inline
156 {
157 fixed (Vector4* p = &this)
158 {
159 int* p2 = (int*) p;
160 return p2[0] ^ p2[1] ^ p2[2] ^ p2[3];
161 }
162 }

◆ GetObjectData()

void BrawlLib.Internal.Vector4.GetObjectData ( SerializationInfo  info,
StreamingContext  context 
)
inline
40 {
41 info.AddValue("_x", _x);
42 info.AddValue("_y", _y);
43 info.AddValue("_z", _z);
44 info.AddValue("_w", _w);
45 }

◆ Length()

float BrawlLib.Internal.Vector4.Length ( )
inline
98 {
99 return (float) Math.Sqrt(Dot());
100 }
float Dot()
Definition: Vector4.cs:102

◆ Length3()

float BrawlLib.Internal.Vector4.Length3 ( )
inline
128 {
129 return (float) Math.Sqrt(Dot3());
130 }
float Dot3()
Definition: Vector4.cs:117

◆ Normalize()

Vector4 BrawlLib.Internal.Vector4.Normalize ( )
inline
113 {
114 return this * (1.0f / Length());
115 }
float Length()
Definition: Vector4.cs:97

◆ Normalize3()

Vector4 BrawlLib.Internal.Vector4.Normalize3 ( )
inline
133 {
134 float scale = 1.0f / Length3();
135 return new Vector4(_x * scale, _y * scale, _z * scale, _w);
136 }
float Length3()
Definition: Vector4.cs:127

◆ operator Vector4()

static BrawlLib.Internal.Vector4.operator Vector4 ( Vector3  v)
inlineexplicitstatic
49 {
50 return new Vector4(v._x, v._y, v._z, 1.0f);
51 }

◆ operator!=()

static bool BrawlLib.Internal.Vector4.operator!= ( Vector4  v1,
Vector4  v2 
)
inlinestatic
93 {
94 return v1._x != v2._x || v1._y != v2._y || v1._z != v2._z || v1._w != v2._w;
95 }

◆ operator*() [1/2]

static Vector4 BrawlLib.Internal.Vector4.operator* ( Vector4  v,
float  f 
)
inlinestatic
54 {
55 return new Vector4(v._x * f, v._y * f, v._z * f, v._w * f);
56 }

◆ operator*() [2/2]

static Vector4 BrawlLib.Internal.Vector4.operator* ( Vector4  v1,
Vector4  v2 
)
inlinestatic
74 {
75 Vector4 v = new Vector4();
76
77 Vector3 x1 = new Vector3(v1._x, v1._y, v1._z);
78 Vector3 x2 = new Vector3(v2._x, v2._y, v2._z);
79 float w1 = v1._w;
80 float w2 = v2._w;
81
82 //Vector3 s = new Vector3(w1 * w2 - x1.Dot(x2), w1 * x2 + w2 * x1 + x1.Cross(x2));
83
84 return v;
85 }

◆ operator+()

static Vector4 BrawlLib.Internal.Vector4.operator+ ( Vector4  v1,
Vector4  v2 
)
inlinestatic
69 {
70 return new Vector4(v1._x + v2._x, v1._y + v2._y, v1._z + v2._z, v1._w + v2._w);
71 }

◆ operator-()

static Vector4 BrawlLib.Internal.Vector4.operator- ( Vector4  v1,
Vector4  v2 
)
inlinestatic
64 {
65 return new Vector4(v1._x - v2._x, v1._y - v2._y, v1._z - v2._z, v1._w - v2._w);
66 }

◆ operator/()

static Vector4 BrawlLib.Internal.Vector4.operator/ ( Vector4  v,
float  f 
)
inlinestatic
59 {
60 return new Vector4(v._x / f, v._y / f, v._z / f, v._w / f);
61 }

◆ operator==()

static bool BrawlLib.Internal.Vector4.operator== ( Vector4  v1,
Vector4  v2 
)
inlinestatic
88 {
89 return v1._x == v2._x && v1._y == v2._y && v1._z == v2._z && v1._w == v2._w;
90 }

◆ ToAxisAngle() [1/2]

Vector4 BrawlLib.Internal.Vector4.ToAxisAngle ( )
inline
198 {
199 Vector4 q = this;
200 if (q._w > 1.0f)
201 {
202 q.Normalize();
203 }
204
205 Vector4 result = new Vector4
206 {
207 _w = 2.0f * (float) Math.Acos(q._w)
208 };
209 float den = (float) Math.Sqrt(1.0 - q._w * q._w);
210 if (den > 0.0001f)
211 {
212 result._x = q._x / den;
213 result._y = q._y / den;
214 result._z = q._z / den;
215 }
216 else
217 {
218 result._x = 1;
219 }
220
221 return result;
222 }

◆ ToAxisAngle() [2/2]

void BrawlLib.Internal.Vector4.ToAxisAngle ( out Vector3  axis,
out float  angle 
)
inline
191 {
192 Vector4 result = ToAxisAngle();
193 axis = new Vector3(result._x, result._y, result._z);
194 angle = result._w;
195 }
Vector4 ToAxisAngle()
Definition: Vector4.cs:197

◆ ToEuler()

Vector3 BrawlLib.Internal.Vector4.ToEuler ( )
inline
259 {
260 return new Vector3(
261 (float) Math.Atan2(2 * (_x * _y + _z * _w), 1 - 2 * (_y * _y + _z * _z)),
262 (float) Math.Asin(2 * (_x * _z - _w * _y)),
263 (float) Math.Atan2(2 * (_x * _w + _y * _z), 1 - 2 * (_z * _z + _w * _w)));
264 }

◆ ToString()

override string BrawlLib.Internal.Vector4.ToString ( )
inline
139 {
140 return CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator.Contains(",")
141 ? $"({_x} {_y} {_z} {_w})"
142 : $"({_x},{_y},{_z},{_w})";
143 }

Member Data Documentation

◆ _w

float BrawlLib.Internal.Vector4._w

◆ _x

float BrawlLib.Internal.Vector4._x

◆ _y

float BrawlLib.Internal.Vector4._y

◆ _z

float BrawlLib.Internal.Vector4._z

◆ Identity

readonly Vector4 BrawlLib.Internal.Vector4.Identity = new Vector4(0, 0, 0, 1)
static

◆ One

readonly Vector4 BrawlLib.Internal.Vector4.One = new Vector4(1, 1, 1, 1)
static

◆ UnitW

readonly Vector4 BrawlLib.Internal.Vector4.UnitW = new Vector4(0, 0, 0, 1)
static

◆ UnitX

readonly Vector4 BrawlLib.Internal.Vector4.UnitX = new Vector4(1, 0, 0, 0)
static

◆ UnitY

readonly Vector4 BrawlLib.Internal.Vector4.UnitY = new Vector4(0, 1, 0, 0)
static

◆ UnitZ

readonly Vector4 BrawlLib.Internal.Vector4.UnitZ = new Vector4(0, 0, 1, 0)
static

◆ Zero

readonly Vector4 BrawlLib.Internal.Vector4.Zero = new Vector4(0, 0, 0, 0)
static

Property Documentation

◆ Address

VoidPtr BrawlLib.Internal.Vector4.Address
get
268 {
269 get
270 {
271 fixed (void* p = &this)
272 {
273 return p;
274 }
275 }
276 }

◆ this[int index]

float BrawlLib.Internal.Vector4.this[int index]
getset
165 {
166 get
167 {
168 fixed (Vector4* p = &this)
169 {
170 return ((float*) p)[index];
171 }
172 }
173 set
174 {
175 fixed (Vector4* p = &this)
176 {
177 ((float*) p)[index] = value;
178 }
179 }
180 }

The documentation for this struct was generated from the following file: