BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Static Public Member Functions | Static Public Attributes | List of all members
BrawlLib.Maths Class Reference

Static Public Member Functions

static float CosLawGetSide (float angle, float a, float b)
 
static float CosLawGetAngle (float a, float b, float c)
 
static Vector3 RotateAboutPoint (Vector3 point, Vector3 center, Vector3 angles)
 
static Vector2 RotateAboutPoint (Vector2 point, Vector2 center, float angle)
 
static Vector3 ScaleAboutPoint (Vector3 point, Vector3 center, Vector3 scale)
 
static Vector2 ScaleAboutPoint (Vector2 point, Vector2 center, Vector2 scale)
 
static Vector3 TransformAboutPoint (Vector3 point, Vector3 center, Matrix transform)
 
static bool LineSphereIntersect (Vector3 start, Vector3 end, Vector3 center, float radius, out Vector3 result)
 
static bool LinePlaneIntersect (Vector3 lineStart, Vector3 lineEnd, Vector3 planePoint, Vector3 planeNormal, out Vector3 result)
 
static Vector3 PointAtLineDistance (Vector3 start, Vector3 end, float distance)
 
static Vector3 PointLineIntersect (Vector3 start, Vector3 end, Vector3 point)
 
static void FFloor3 (float *v)
 
static void FMult3 (float *l, float *r)
 
static void FMult3 (float *l, float r)
 
static void FAdd3 (float *l, float *r)
 
static void FAdd3 (float *l, float r)
 
static void FSub3 (float *l, float *r)
 
static float Power (float value, int amount)
 
static float Bezier (float p0, float p1, float p2, float p3, float t)
 
static float Max (params float[] values)
 
static int Max (params int[] values)
 
static uint Max (params uint[] values)
 
static short Max (params short[] values)
 
static ushort Max (params ushort[] values)
 
static byte Max (params byte[] values)
 
static sbyte Max (params sbyte[] values)
 
static float Min (params float[] values)
 
static int Min (params int[] values)
 
static uint Min (params uint[] values)
 
static short Min (params short[] values)
 
static ushort Min (params ushort[] values)
 
static byte Min (params byte[] values)
 
static sbyte Min (params sbyte[] values)
 

Static Public Attributes

const double _rad2deg = 180.0 / Math.PI
 
const double _deg2rad = Math.PI / 180.0
 
const float _rad2degf = (float) _rad2deg
 
const float _deg2radf = (float) _deg2rad
 
const float _pif = (float) Math.PI
 
const float _halfPif = (float) (Math.PI / 2.0)
 

Member Function Documentation

◆ Bezier()

static float BrawlLib.Maths.Bezier ( float  p0,
float  p1,
float  p2,
float  p3,
float  t 
)
inlinestatic
182 {
183 return
184 Power(1 - t, 3) * p0 +
185 3 * Power(1 - t, 2) * t * p1 +
186 3 * (1 - t) * Power(t, 2) * p2 +
187 Power(t, 3) * p3;
188 }
static float Power(float value, int amount)
Definition: Maths.cs:169

◆ CosLawGetAngle()

static float BrawlLib.Maths.CosLawGetAngle ( float  a,
float  b,
float  c 
)
inlinestatic
25 {
26 return (float) Math.Acos((a * a + b * b - c * c) / (2 * a * b));
27 }

◆ CosLawGetSide()

static float BrawlLib.Maths.CosLawGetSide ( float  angle,
float  a,
float  b 
)
inlinestatic
20 {
21 return (float) Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(angle * _deg2radf));
22 }
const float _deg2radf
Definition: Maths.cs:14

◆ FAdd3() [1/2]

static void BrawlLib.Maths.FAdd3 ( float *  l,
float *  r 
)
inlinestatic
149 {
150 *l++ += *r++;
151 *l++ += *r++;
152 *l++ += *r++;
153 }

◆ FAdd3() [2/2]

static void BrawlLib.Maths.FAdd3 ( float *  l,
float  r 
)
inlinestatic
156 {
157 *l++ += r;
158 *l++ += r;
159 *l++ += r;
160 }

◆ FFloor3()

static void BrawlLib.Maths.FFloor3 ( float *  v)
inlinestatic
123 {
124 double d;
125 int* p = (int*) &d;
126 int i = 3;
127 while (i-- > 0)
128 {
129 d = v[i] + _double2fixmagic;
130 v[i] = *p >> 16;
131 }
132 }

◆ FMult3() [1/2]

static void BrawlLib.Maths.FMult3 ( float *  l,
float *  r 
)
inlinestatic
135 {
136 *l++ *= *r++;
137 *l++ *= *r++;
138 *l++ *= *r++;
139 }

◆ FMult3() [2/2]

static void BrawlLib.Maths.FMult3 ( float *  l,
float  r 
)
inlinestatic
142 {
143 *l++ *= r;
144 *l++ *= r;
145 *l++ *= r;
146 }

◆ FSub3()

static void BrawlLib.Maths.FSub3 ( float *  l,
float *  r 
)
inlinestatic
163 {
164 *l++ -= *r++;
165 *l++ -= *r++;
166 *l++ -= *r++;
167 }

◆ LinePlaneIntersect()

static bool BrawlLib.Maths.LinePlaneIntersect ( Vector3  lineStart,
Vector3  lineEnd,
Vector3  planePoint,
Vector3  planeNormal,
out Vector3  result 
)
inlinestatic
96 {
97 Vector3 diff = lineEnd - lineStart;
98 float scale = -planeNormal.Dot(lineStart - planePoint) / planeNormal.Dot(diff);
99
100 if (float.IsNaN(scale) || scale < 0.0f || scale > 1.0f)
101 {
102 result = new Vector3();
103 return false;
104 }
105
106 result = lineStart + diff * scale;
107 return true;
108 }
Definition: Vector3.cs:40
static float Dot(Vector3 v1, Vector3 v2)
Definition: Vector3.cs:284

◆ LineSphereIntersect()

static bool BrawlLib.Maths.LineSphereIntersect ( Vector3  start,
Vector3  end,
Vector3  center,
float  radius,
out Vector3  result 
)
inlinestatic
61 {
62 Vector3 diff = end - start;
63 float a = diff.Dot();
64
65 if (a > 0.0f)
66 {
67 float b = 2 * diff.Dot(start - center);
68 float c = center.Dot() + start.Dot() - 2 * center.Dot(start) - radius * radius;
69
70 float magnitude = b * b - 4 * a * c;
71
72 if (magnitude >= 0.0f)
73 {
74 magnitude = (float) Math.Sqrt(magnitude);
75 a *= 2;
76
77 float scale = (-b + magnitude) / a;
78 float dist2 = (-b - magnitude) / a;
79
80 if (dist2 < scale)
81 {
82 scale = dist2;
83 }
84
85 result = start + diff * scale;
86 return true;
87 }
88 }
89
90 result = new Vector3();
91 return false;
92 }

◆ Max() [1/7]

static byte BrawlLib.Maths.Max ( params byte[]  values)
inlinestatic
261 {
262 byte v = values[0];
263 if (values.Length > 1)
264 {
265 for (int i = 1; i < values.Length; i++)
266 {
267 v = Math.Max(v, values[i]);
268 }
269 }
270
271 return v;
272 }

◆ Max() [2/7]

static float BrawlLib.Maths.Max ( params float[]  values)
inlinestatic
191 {
192 float v = values[0];
193 if (values.Length > 1)
194 {
195 for (int i = 1; i < values.Length; i++)
196 {
197 v = Math.Max(v, values[i]);
198 }
199 }
200
201 return v;
202 }

◆ Max() [3/7]

static int BrawlLib.Maths.Max ( params int[]  values)
inlinestatic
205 {
206 int v = values[0];
207 if (values.Length > 1)
208 {
209 for (int i = 1; i < values.Length; i++)
210 {
211 v = Math.Max(v, values[i]);
212 }
213 }
214
215 return v;
216 }

◆ Max() [4/7]

static sbyte BrawlLib.Maths.Max ( params sbyte[]  values)
inlinestatic
275 {
276 sbyte v = values[0];
277 if (values.Length > 1)
278 {
279 for (int i = 1; i < values.Length; i++)
280 {
281 v = Math.Max(v, values[i]);
282 }
283 }
284
285 return v;
286 }

◆ Max() [5/7]

static short BrawlLib.Maths.Max ( params short[]  values)
inlinestatic
233 {
234 short v = values[0];
235 if (values.Length > 1)
236 {
237 for (int i = 1; i < values.Length; i++)
238 {
239 v = Math.Max(v, values[i]);
240 }
241 }
242
243 return v;
244 }

◆ Max() [6/7]

static uint BrawlLib.Maths.Max ( params uint[]  values)
inlinestatic
219 {
220 uint v = values[0];
221 if (values.Length > 1)
222 {
223 for (int i = 1; i < values.Length; i++)
224 {
225 v = Math.Max(v, values[i]);
226 }
227 }
228
229 return v;
230 }

◆ Max() [7/7]

static ushort BrawlLib.Maths.Max ( params ushort[]  values)
inlinestatic
247 {
248 ushort v = values[0];
249 if (values.Length > 1)
250 {
251 for (int i = 1; i < values.Length; i++)
252 {
253 v = Math.Max(v, values[i]);
254 }
255 }
256
257 return v;
258 }

◆ Min() [1/7]

static byte BrawlLib.Maths.Min ( params byte[]  values)
inlinestatic
359 {
360 byte v = values[0];
361 if (values.Length > 1)
362 {
363 for (int i = 1; i < values.Length; i++)
364 {
365 v = Math.Min(v, values[i]);
366 }
367 }
368
369 return v;
370 }

◆ Min() [2/7]

static float BrawlLib.Maths.Min ( params float[]  values)
inlinestatic
289 {
290 float v = values[0];
291 if (values.Length > 1)
292 {
293 for (int i = 1; i < values.Length; i++)
294 {
295 v = Math.Min(v, values[i]);
296 }
297 }
298
299 return v;
300 }

◆ Min() [3/7]

static int BrawlLib.Maths.Min ( params int[]  values)
inlinestatic
303 {
304 int v = values[0];
305 if (values.Length > 1)
306 {
307 for (int i = 1; i < values.Length; i++)
308 {
309 v = Math.Min(v, values[i]);
310 }
311 }
312
313 return v;
314 }

◆ Min() [4/7]

static sbyte BrawlLib.Maths.Min ( params sbyte[]  values)
inlinestatic
373 {
374 sbyte v = values[0];
375 if (values.Length > 1)
376 {
377 for (int i = 1; i < values.Length; i++)
378 {
379 v = Math.Min(v, values[i]);
380 }
381 }
382
383 return v;
384 }

◆ Min() [5/7]

static short BrawlLib.Maths.Min ( params short[]  values)
inlinestatic
331 {
332 short v = values[0];
333 if (values.Length > 1)
334 {
335 for (int i = 1; i < values.Length; i++)
336 {
337 v = Math.Min(v, values[i]);
338 }
339 }
340
341 return v;
342 }

◆ Min() [6/7]

static uint BrawlLib.Maths.Min ( params uint[]  values)
inlinestatic
317 {
318 uint v = values[0];
319 if (values.Length > 1)
320 {
321 for (int i = 1; i < values.Length; i++)
322 {
323 v = Math.Min(v, values[i]);
324 }
325 }
326
327 return v;
328 }

◆ Min() [7/7]

static ushort BrawlLib.Maths.Min ( params ushort[]  values)
inlinestatic
345 {
346 ushort v = values[0];
347 if (values.Length > 1)
348 {
349 for (int i = 1; i < values.Length; i++)
350 {
351 v = Math.Min(v, values[i]);
352 }
353 }
354
355 return v;
356 }

◆ PointAtLineDistance()

static Vector3 BrawlLib.Maths.PointAtLineDistance ( Vector3  start,
Vector3  end,
float  distance 
)
inlinestatic
111 {
112 Vector3 diff = end - start;
113 return start + diff * (distance / diff.TrueDistance());
114 }
float TrueDistance(Vector3 p)
Definition: Vector3.cs:497

◆ PointLineIntersect()

static Vector3 BrawlLib.Maths.PointLineIntersect ( Vector3  start,
Vector3  end,
Vector3  point 
)
inlinestatic
117 {
118 Vector3 diff = end - start;
119 return start + diff * (diff.Dot(point - start) / diff.Dot());
120 }

◆ Power()

static float BrawlLib.Maths.Power ( float  value,
int  amount 
)
inlinestatic
170 {
171 int i = 0;
172 float result = 1;
173 for (i = 0; i < amount; i++)
174 {
175 result *= value;
176 }
177
178 return value;
179 }

◆ RotateAboutPoint() [1/2]

static Vector2 BrawlLib.Maths.RotateAboutPoint ( Vector2  point,
Vector2  center,
float  angle 
)
inlinestatic
36 {
37 return (Vector2) ((Vector3) point * Matrix.TranslationMatrix((Vector3) (-center)) *
39 }
Definition: Matrix.cs:14
static Matrix TranslationMatrix(Vector3 v)
Definition: Matrix.cs:353
static Matrix RotationAboutZ(float angle)
Definition: Matrix.cs:447
Definition: Vector2.cs:10

◆ RotateAboutPoint() [2/2]

static Vector3 BrawlLib.Maths.RotateAboutPoint ( Vector3  point,
Vector3  center,
Vector3  angles 
)
inlinestatic
30 {
31 return point * Matrix.TranslationMatrix(-center) * Matrix.RotationMatrix(angles) *
33 }
static Matrix RotationMatrix(Vector3 angles)
Definition: Matrix.cs:465

◆ ScaleAboutPoint() [1/2]

static Vector2 BrawlLib.Maths.ScaleAboutPoint ( Vector2  point,
Vector2  center,
Vector2  scale 
)
inlinestatic
48 {
49 return (Vector2) ((Vector3) point * Matrix.TranslationMatrix((Vector3) (-center)) *
50 Matrix.ScaleMatrix(scale._x, scale._y, 1.0f) *
52 }
static Matrix ScaleMatrix(Vector3 scale)
Definition: Matrix.cs:337
float _y
Definition: Vector2.cs:17
float _x
Definition: Vector2.cs:11

◆ ScaleAboutPoint() [2/2]

static Vector3 BrawlLib.Maths.ScaleAboutPoint ( Vector3  point,
Vector3  center,
Vector3  scale 
)
inlinestatic
42 {
43 return point * Matrix.TranslationMatrix(-center) * Matrix.ScaleMatrix(scale) *
45 }

◆ TransformAboutPoint()

static Vector3 BrawlLib.Maths.TransformAboutPoint ( Vector3  point,
Vector3  center,
Matrix  transform 
)
inlinestatic
55 {
56 return point * Matrix.TranslationMatrix(-center) * transform * Matrix.TranslationMatrix(center);
57 }

Member Data Documentation

◆ _deg2rad

const double BrawlLib.Maths._deg2rad = Math.PI / 180.0
static

◆ _deg2radf

const float BrawlLib.Maths._deg2radf = (float) _deg2rad
static

◆ _halfPif

const float BrawlLib.Maths._halfPif = (float) (Math.PI / 2.0)
static

◆ _pif

const float BrawlLib.Maths._pif = (float) Math.PI
static

◆ _rad2deg

const double BrawlLib.Maths._rad2deg = 180.0 / Math.PI
static

◆ _rad2degf

const float BrawlLib.Maths._rad2degf = (float) _rad2deg
static

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