LiquidFun
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
b2Math.h
1 /*
2 * Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
3 *
4 * This software is provided 'as-is', without any express or implied
5 * warranty. In no event will the authors be held liable for any damages
6 * arising from the use of this software.
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 * 1. The origin of this software must not be misrepresented; you must not
11 * claim that you wrote the original software. If you use this software
12 * in a product, an acknowledgment in the product documentation would be
13 * appreciated but is not required.
14 * 2. Altered source versions must be plainly marked as such, and must not be
15 * misrepresented as being the original software.
16 * 3. This notice may not be removed or altered from any source distribution.
17 */
18 
19 #ifndef B2_MATH_H
20 #define B2_MATH_H
21 
23 #include <math.h>
24 
26 inline bool b2IsValid(float32 x)
27 {
28  union {
29  float32 f;
30  int32 i;
31  } v = { x };
32  return (v.i & 0x7f800000) != 0x7f800000;
33 }
34 
36 inline float32 b2InvSqrt(float32 x)
37 {
38  union
39  {
40  float32 x;
41  int32 i;
42  } convert;
43 
44  convert.x = x;
45  float32 xhalf = 0.5f * x;
46  convert.i = 0x5f3759df - (convert.i >> 1);
47  x = convert.x;
48  x = x * (1.5f - xhalf * x * x);
49  return x;
50 }
51 
52 #define b2Sqrt(x) sqrtf(x)
53 #define b2Atan2(y, x) atan2f(y, x)
54 
56 struct b2Vec2
57 {
59  b2Vec2() {}
60 
62  b2Vec2(float32 x, float32 y) : x(x), y(y) {}
63 
65  void SetZero() { x = 0.0f; y = 0.0f; }
66 
68  void Set(float32 x_, float32 y_) { x = x_; y = y_; }
69 
71  b2Vec2 operator -() const { b2Vec2 v; v.Set(-x, -y); return v; }
72 
74  float32 operator () (int32 i) const
75  {
76  return (&x)[i];
77  }
78 
80  float32& operator () (int32 i)
81  {
82  return (&x)[i];
83  }
84 
86  void operator += (const b2Vec2& v)
87  {
88  x += v.x; y += v.y;
89  }
90 
92  void operator -= (const b2Vec2& v)
93  {
94  x -= v.x; y -= v.y;
95  }
96 
98  void operator *= (float32 a)
99  {
100  x *= a; y *= a;
101  }
102 
104  float32 Length() const
105  {
106  return b2Sqrt(x * x + y * y);
107  }
108 
111  float32 LengthSquared() const
112  {
113  return x * x + y * y;
114  }
115 
117  float32 Normalize()
118  {
119  float32 length = Length();
120  if (length < b2_epsilon)
121  {
122  return 0.0f;
123  }
124  float32 invLength = 1.0f / length;
125  x *= invLength;
126  y *= invLength;
127 
128  return length;
129  }
130 
132  bool IsValid() const
133  {
134  return b2IsValid(x) && b2IsValid(y);
135  }
136 
138  b2Vec2 Skew() const
139  {
140  return b2Vec2(-y, x);
141  }
142 
143  float32 x, y;
144 };
145 
147 inline b2Vec2 operator + (const b2Vec2& v, float f)
148 {
149  return b2Vec2(v.x + f, v.y + f);
150 }
151 
153 inline b2Vec2 operator - (const b2Vec2& v, float f)
154 {
155  return b2Vec2(v.x - f, v.y - f);
156 }
157 
159 inline b2Vec2 operator * (const b2Vec2& v, float f)
160 {
161  return b2Vec2(v.x * f, v.y * f);
162 }
163 
165 inline b2Vec2 operator / (const b2Vec2& v, float f)
166 {
167  return b2Vec2(v.x / f, v.y / f);
168 }
169 
171 struct b2Vec3
172 {
174  b2Vec3() {}
175 
177  b2Vec3(float32 x, float32 y, float32 z) : x(x), y(y), z(z) {}
178 
180  void SetZero() { x = 0.0f; y = 0.0f; z = 0.0f; }
181 
183  void Set(float32 x_, float32 y_, float32 z_) { x = x_; y = y_; z = z_; }
184 
186  b2Vec3 operator -() const { b2Vec3 v; v.Set(-x, -y, -z); return v; }
187 
189  void operator += (const b2Vec3& v)
190  {
191  x += v.x; y += v.y; z += v.z;
192  }
193 
195  void operator -= (const b2Vec3& v)
196  {
197  x -= v.x; y -= v.y; z -= v.z;
198  }
199 
201  void operator *= (float32 s)
202  {
203  x *= s; y *= s; z *= s;
204  }
205 
207  float32 Length() const
208  {
209  return b2Sqrt(x * x + y * y + z * z);
210  }
211 
213  float32 Normalize()
214  {
215  float32 length = Length();
216  if (length < b2_epsilon)
217  {
218  return 0.0f;
219  }
220  float32 invLength = 1.0f / length;
221  x *= invLength;
222  y *= invLength;
223  z *= invLength;
224 
225  return length;
226  }
227 
228  float32 x, y, z;
229 };
230 
232 struct b2Vec4
233 {
235  b2Vec4() {}
236 
238  b2Vec4(float32 x, float32 y, float32 z, float32 w) : x(x), y(y), z(z), w(w) {}
239 
240  float32 x, y, z, w;
241 };
242 
244 struct b2Mat22
245 {
247  b2Mat22() {}
248 
250  b2Mat22(const b2Vec2& c1, const b2Vec2& c2)
251  {
252  ex = c1;
253  ey = c2;
254  }
255 
257  b2Mat22(float32 a11, float32 a12, float32 a21, float32 a22)
258  {
259  ex.x = a11; ex.y = a21;
260  ey.x = a12; ey.y = a22;
261  }
262 
264  void Set(const b2Vec2& c1, const b2Vec2& c2)
265  {
266  ex = c1;
267  ey = c2;
268  }
269 
271  void SetIdentity()
272  {
273  ex.x = 1.0f; ey.x = 0.0f;
274  ex.y = 0.0f; ey.y = 1.0f;
275  }
276 
278  void SetZero()
279  {
280  ex.x = 0.0f; ey.x = 0.0f;
281  ex.y = 0.0f; ey.y = 0.0f;
282  }
283 
284  b2Mat22 GetInverse() const
285  {
286  float32 a = ex.x, b = ey.x, c = ex.y, d = ey.y;
287  b2Mat22 B;
288  float32 det = a * d - b * c;
289  if (det != 0.0f)
290  {
291  det = 1.0f / det;
292  }
293  B.ex.x = det * d; B.ey.x = -det * b;
294  B.ex.y = -det * c; B.ey.y = det * a;
295  return B;
296  }
297 
300  b2Vec2 Solve(const b2Vec2& b) const
301  {
302  float32 a11 = ex.x, a12 = ey.x, a21 = ex.y, a22 = ey.y;
303  float32 det = a11 * a22 - a12 * a21;
304  if (det != 0.0f)
305  {
306  det = 1.0f / det;
307  }
308  b2Vec2 x;
309  x.x = det * (a22 * b.x - a12 * b.y);
310  x.y = det * (a11 * b.y - a21 * b.x);
311  return x;
312  }
313 
314  b2Vec2 ex, ey;
315 };
316 
318 struct b2Mat33
319 {
321  b2Mat33() {}
322 
324  b2Mat33(const b2Vec3& c1, const b2Vec3& c2, const b2Vec3& c3)
325  {
326  ex = c1;
327  ey = c2;
328  ez = c3;
329  }
330 
332  void SetZero()
333  {
334  ex.SetZero();
335  ey.SetZero();
336  ez.SetZero();
337  }
338 
341  b2Vec3 Solve33(const b2Vec3& b) const;
342 
346  b2Vec2 Solve22(const b2Vec2& b) const;
347 
350  void GetInverse22(b2Mat33* M) const;
351 
354  void GetSymInverse33(b2Mat33* M) const;
355 
356  b2Vec3 ex, ey, ez;
357 };
358 
360 struct b2Rot
361 {
362  b2Rot() {}
363 
365  explicit b2Rot(float32 angle)
366  {
368  s = sinf(angle);
369  c = cosf(angle);
370  }
371 
373  void Set(float32 angle)
374  {
376  s = sinf(angle);
377  c = cosf(angle);
378  }
379 
381  void SetIdentity()
382  {
383  s = 0.0f;
384  c = 1.0f;
385  }
386 
388  float32 GetAngle() const
389  {
390  return b2Atan2(s, c);
391  }
392 
394  b2Vec2 GetXAxis() const
395  {
396  return b2Vec2(c, s);
397  }
398 
400  b2Vec2 GetYAxis() const
401  {
402  return b2Vec2(-s, c);
403  }
404 
406  float32 s, c;
407 };
408 
412 {
415 
417  b2Transform(const b2Vec2& position, const b2Rot& rotation) : p(position), q(rotation) {}
418 
420  void SetIdentity()
421  {
422  p.SetZero();
423  q.SetIdentity();
424  }
425 
427  void Set(const b2Vec2& position, float32 angle)
428  {
429  p = position;
430  q.Set(angle);
431  }
432 
433  b2Vec2 p;
434  b2Rot q;
435 };
436 
441 struct b2Sweep
442 {
445  void GetTransform(b2Transform* xfb, float32 beta) const;
446 
449  void Advance(float32 alpha);
450 
452  void Normalize();
453 
455  b2Vec2 c0, c;
456  float32 a0, a;
457 
460  float32 alpha0;
461 };
462 
464 extern const b2Vec2 b2Vec2_zero;
465 
467 inline float32 b2Dot(const b2Vec2& a, const b2Vec2& b)
468 {
469  return a.x * b.x + a.y * b.y;
470 }
471 
473 inline float32 b2Cross(const b2Vec2& a, const b2Vec2& b)
474 {
475  return a.x * b.y - a.y * b.x;
476 }
477 
480 inline b2Vec2 b2Cross(const b2Vec2& a, float32 s)
481 {
482  return b2Vec2(s * a.y, -s * a.x);
483 }
484 
487 inline b2Vec2 b2Cross(float32 s, const b2Vec2& a)
488 {
489  return b2Vec2(-s * a.y, s * a.x);
490 }
491 
494 inline b2Vec2 b2Mul(const b2Mat22& A, const b2Vec2& v)
495 {
496  return b2Vec2(A.ex.x * v.x + A.ey.x * v.y, A.ex.y * v.x + A.ey.y * v.y);
497 }
498 
501 inline b2Vec2 b2MulT(const b2Mat22& A, const b2Vec2& v)
502 {
503  return b2Vec2(b2Dot(v, A.ex), b2Dot(v, A.ey));
504 }
505 
507 inline b2Vec2 operator + (const b2Vec2& a, const b2Vec2& b)
508 {
509  return b2Vec2(a.x + b.x, a.y + b.y);
510 }
511 
513 inline b2Vec2 operator - (const b2Vec2& a, const b2Vec2& b)
514 {
515  return b2Vec2(a.x - b.x, a.y - b.y);
516 }
517 
518 inline b2Vec2 operator * (float32 s, const b2Vec2& a)
519 {
520  return b2Vec2(s * a.x, s * a.y);
521 }
522 
523 inline bool operator == (const b2Vec2& a, const b2Vec2& b)
524 {
525  return a.x == b.x && a.y == b.y;
526 }
527 
528 inline bool operator != (const b2Vec2& a, const b2Vec2& b)
529 {
530  return !operator==(a, b);
531 }
532 
533 inline float32 b2Distance(const b2Vec2& a, const b2Vec2& b)
534 {
535  b2Vec2 c = a - b;
536  return c.Length();
537 }
538 
539 inline float32 b2DistanceSquared(const b2Vec2& a, const b2Vec2& b)
540 {
541  b2Vec2 c = a - b;
542  return b2Dot(c, c);
543 }
544 
545 inline b2Vec3 operator * (float32 s, const b2Vec3& a)
546 {
547  return b2Vec3(s * a.x, s * a.y, s * a.z);
548 }
549 
551 inline b2Vec3 operator + (const b2Vec3& a, const b2Vec3& b)
552 {
553  return b2Vec3(a.x + b.x, a.y + b.y, a.z + b.z);
554 }
555 
557 inline b2Vec3 operator - (const b2Vec3& a, const b2Vec3& b)
558 {
559  return b2Vec3(a.x - b.x, a.y - b.y, a.z - b.z);
560 }
561 
563 inline float32 b2Dot(const b2Vec3& a, const b2Vec3& b)
564 {
565  return a.x * b.x + a.y * b.y + a.z * b.z;
566 }
567 
569 inline b2Vec3 b2Cross(const b2Vec3& a, const b2Vec3& b)
570 {
571  return b2Vec3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
572 }
573 
574 inline b2Mat22 operator + (const b2Mat22& A, const b2Mat22& B)
575 {
576  return b2Mat22(A.ex + B.ex, A.ey + B.ey);
577 }
578 
579 // A * B
580 inline b2Mat22 b2Mul(const b2Mat22& A, const b2Mat22& B)
581 {
582  return b2Mat22(b2Mul(A, B.ex), b2Mul(A, B.ey));
583 }
584 
585 // A^T * B
586 inline b2Mat22 b2MulT(const b2Mat22& A, const b2Mat22& B)
587 {
588  b2Vec2 c1(b2Dot(A.ex, B.ex), b2Dot(A.ey, B.ex));
589  b2Vec2 c2(b2Dot(A.ex, B.ey), b2Dot(A.ey, B.ey));
590  return b2Mat22(c1, c2);
591 }
592 
594 inline b2Vec3 b2Mul(const b2Mat33& A, const b2Vec3& v)
595 {
596  return v.x * A.ex + v.y * A.ey + v.z * A.ez;
597 }
598 
600 inline b2Vec2 b2Mul22(const b2Mat33& A, const b2Vec2& v)
601 {
602  return b2Vec2(A.ex.x * v.x + A.ey.x * v.y, A.ex.y * v.x + A.ey.y * v.y);
603 }
604 
606 inline b2Rot b2Mul(const b2Rot& q, const b2Rot& r)
607 {
608  // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]
609  // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]
610  // s = qs * rc + qc * rs
611  // c = qc * rc - qs * rs
612  b2Rot qr;
613  qr.s = q.s * r.c + q.c * r.s;
614  qr.c = q.c * r.c - q.s * r.s;
615  return qr;
616 }
617 
619 inline b2Rot b2MulT(const b2Rot& q, const b2Rot& r)
620 {
621  // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]
622  // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]
623  // s = qc * rs - qs * rc
624  // c = qc * rc + qs * rs
625  b2Rot qr;
626  qr.s = q.c * r.s - q.s * r.c;
627  qr.c = q.c * r.c + q.s * r.s;
628  return qr;
629 }
630 
632 inline b2Vec2 b2Mul(const b2Rot& q, const b2Vec2& v)
633 {
634  return b2Vec2(q.c * v.x - q.s * v.y, q.s * v.x + q.c * v.y);
635 }
636 
638 inline b2Vec2 b2MulT(const b2Rot& q, const b2Vec2& v)
639 {
640  return b2Vec2(q.c * v.x + q.s * v.y, -q.s * v.x + q.c * v.y);
641 }
642 
643 inline b2Vec2 b2Mul(const b2Transform& T, const b2Vec2& v)
644 {
645  float32 x = (T.q.c * v.x - T.q.s * v.y) + T.p.x;
646  float32 y = (T.q.s * v.x + T.q.c * v.y) + T.p.y;
647 
648  return b2Vec2(x, y);
649 }
650 
651 inline b2Vec2 b2MulT(const b2Transform& T, const b2Vec2& v)
652 {
653  float32 px = v.x - T.p.x;
654  float32 py = v.y - T.p.y;
655  float32 x = (T.q.c * px + T.q.s * py);
656  float32 y = (-T.q.s * px + T.q.c * py);
657 
658  return b2Vec2(x, y);
659 }
660 
661 // v2 = A.q.Rot(B.q.Rot(v1) + B.p) + A.p
662 // = (A.q * B.q).Rot(v1) + A.q.Rot(B.p) + A.p
663 inline b2Transform b2Mul(const b2Transform& A, const b2Transform& B)
664 {
665  b2Transform C;
666  C.q = b2Mul(A.q, B.q);
667  C.p = b2Mul(A.q, B.p) + A.p;
668  return C;
669 }
670 
671 // v2 = A.q' * (B.q * v1 + B.p - A.p)
672 // = A.q' * B.q * v1 + A.q' * (B.p - A.p)
673 inline b2Transform b2MulT(const b2Transform& A, const b2Transform& B)
674 {
675  b2Transform C;
676  C.q = b2MulT(A.q, B.q);
677  C.p = b2MulT(A.q, B.p - A.p);
678  return C;
679 }
680 
681 template <typename T>
682 inline T b2Abs(T a)
683 {
684  return a > T(0) ? a : -a;
685 }
686 
687 inline b2Vec2 b2Abs(const b2Vec2& a)
688 {
689  return b2Vec2(b2Abs(a.x), b2Abs(a.y));
690 }
691 
692 inline b2Mat22 b2Abs(const b2Mat22& A)
693 {
694  return b2Mat22(b2Abs(A.ex), b2Abs(A.ey));
695 }
696 
697 template <typename T>
698 inline T b2Min(T a, T b)
699 {
700  return a < b ? a : b;
701 }
702 
703 inline b2Vec2 b2Min(const b2Vec2& a, const b2Vec2& b)
704 {
705  return b2Vec2(b2Min(a.x, b.x), b2Min(a.y, b.y));
706 }
707 
708 template <typename T>
709 inline T b2Max(T a, T b)
710 {
711  return a > b ? a : b;
712 }
713 
714 inline b2Vec2 b2Max(const b2Vec2& a, const b2Vec2& b)
715 {
716  return b2Vec2(b2Max(a.x, b.x), b2Max(a.y, b.y));
717 }
718 
719 template <typename T>
720 inline T b2Clamp(T a, T low, T high)
721 {
722  return b2Max(low, b2Min(a, high));
723 }
724 
725 inline b2Vec2 b2Clamp(const b2Vec2& a, const b2Vec2& low, const b2Vec2& high)
726 {
727  return b2Max(low, b2Min(a, high));
728 }
729 
730 template<typename T> inline void b2Swap(T& a, T& b)
731 {
732  T tmp = a;
733  a = b;
734  b = tmp;
735 }
736 
742 inline uint32 b2NextPowerOfTwo(uint32 x)
743 {
744  x |= (x >> 1);
745  x |= (x >> 2);
746  x |= (x >> 4);
747  x |= (x >> 8);
748  x |= (x >> 16);
749  return x + 1;
750 }
751 
752 inline bool b2IsPowerOfTwo(uint32 x)
753 {
754  bool result = x > 0 && (x & (x - 1)) == 0;
755  return result;
756 }
757 
758 inline void b2Sweep::GetTransform(b2Transform* xf, float32 beta) const
759 {
760  xf->p = (1.0f - beta) * c0 + beta * c;
761  float32 angle = (1.0f - beta) * a0 + beta * a;
762  xf->q.Set(angle);
763 
764  // Shift to origin
765  xf->p -= b2Mul(xf->q, localCenter);
766 }
767 
768 inline void b2Sweep::Advance(float32 alpha)
769 {
770  b2Assert(alpha0 < 1.0f);
771  float32 beta = (alpha - alpha0) / (1.0f - alpha0);
772  c0 += beta * (c - c0);
773  a0 += beta * (a - a0);
774  alpha0 = alpha;
775 }
776 
778 inline void b2Sweep::Normalize()
779 {
780  float32 twoPi = 2.0f * b2_pi;
781  float32 d = twoPi * floorf(a0 / twoPi);
782  a0 -= d;
783  a -= d;
784 }
785 
786 #endif
b2Vec2 Solve22(const b2Vec2 &b) const
Definition: b2Math.cpp:41
Definition: b2Math.h:411
b2Transform()
The default constructor does nothing.
Definition: b2Math.h:414
b2Vec3(float32 x, float32 y, float32 z)
Construct using coordinates.
Definition: b2Math.h:177
void GetTransform(b2Transform *xfb, float32 beta) const
Definition: b2Math.h:758
b2Vec4()
Default constructor does nothing (for performance).
Definition: b2Math.h:235
A 3D column vector with 3 elements.
Definition: b2Math.h:171
float32 GetAngle() const
Get the angle in radians.
Definition: b2Math.h:388
bool IsValid() const
Does this vector contain finite coordinates?
Definition: b2Math.h:132
b2Mat22(const b2Vec2 &c1, const b2Vec2 &c2)
Construct this matrix using columns.
Definition: b2Math.h:250
float32 Length() const
Get the length of this vector (the norm).
Definition: b2Math.h:207
b2Vec3()
Default constructor does nothing (for performance).
Definition: b2Math.h:174
A 3-by-3 matrix. Stored in column-major order.
Definition: b2Math.h:318
b2Vec2()
Default constructor does nothing (for performance).
Definition: b2Math.h:59
void Set(float32 x_, float32 y_, float32 z_)
Set this vector to some specified coordinates.
Definition: b2Math.h:183
float32 Normalize()
Convert this vector into a unit vector. Returns the length.
Definition: b2Math.h:117
b2Vec2 GetYAxis() const
Get the u-axis.
Definition: b2Math.h:400
b2Mat33()
The default constructor does nothing (for performance).
Definition: b2Math.h:321
b2Vec2 operator-() const
Negate this vector.
Definition: b2Math.h:71
A 4D column vector with 4 elements.
Definition: b2Math.h:232
b2Vec2(float32 x, float32 y)
Construct using coordinates.
Definition: b2Math.h:62
Definition: b2Math.h:441
b2Mat22()
The default constructor does nothing (for performance).
Definition: b2Math.h:247
float32 s
Sine and cosine.
Definition: b2Math.h:406
float32 a
world angles
Definition: b2Math.h:456
b2Mat33(const b2Vec3 &c1, const b2Vec3 &c2, const b2Vec3 &c3)
Construct this matrix using columns.
Definition: b2Math.h:324
b2Vec2 Skew() const
Get the skew vector such that dot(skew_vec, other) == cross(vec, other)
Definition: b2Math.h:138
b2Vec2 GetXAxis() const
Get the x-axis.
Definition: b2Math.h:394
b2Vec3 operator-() const
Negate this vector.
Definition: b2Math.h:186
void Set(float32 x_, float32 y_)
Set this vector to some specified coordinates.
Definition: b2Math.h:68
float32 Normalize()
Convert this vector into a unit vector. Returns the length.
Definition: b2Math.h:213
void Set(const b2Vec2 &position, float32 angle)
Set this based on the position and angle.
Definition: b2Math.h:427
void SetZero()
Set this vector to all zeros.
Definition: b2Math.h:65
void operator+=(const b2Vec2 &v)
Add a vector to this vector.
Definition: b2Math.h:86
void GetInverse22(b2Mat33 *M) const
Definition: b2Math.cpp:56
void operator*=(float32 s)
Multiply this vector by a scalar.
Definition: b2Math.h:201
void SetIdentity()
Set this to the identity transform.
Definition: b2Math.h:420
void operator-=(const b2Vec2 &v)
Subtract a vector from this vector.
Definition: b2Math.h:92
void SetZero()
Set this vector to all zeros.
Definition: b2Math.h:180
void operator-=(const b2Vec3 &v)
Subtract a vector from this vector.
Definition: b2Math.h:195
b2Rot(float32 angle)
Initialize from an angle in radians.
Definition: b2Math.h:365
void operator+=(const b2Vec3 &v)
Add a vector to this vector.
Definition: b2Math.h:189
b2Vec2 Solve(const b2Vec2 &b) const
Definition: b2Math.h:300
b2Vec2 c
center world positions
Definition: b2Math.h:455
float32 Length() const
Get the length of this vector (the norm).
Definition: b2Math.h:104
b2Vec2 localCenter
local center of mass position
Definition: b2Math.h:454
void GetSymInverse33(b2Mat33 *M) const
Returns the zero matrix if singular.
Definition: b2Math.cpp:71
A 2-by-2 matrix. Stored in column-major order.
Definition: b2Math.h:244
void Set(const b2Vec2 &c1, const b2Vec2 &c2)
Initialize this matrix using columns.
Definition: b2Math.h:264
b2Vec4(float32 x, float32 y, float32 z, float32 w)
Construct using coordinates.
Definition: b2Math.h:238
void SetIdentity()
Set to the identity rotation.
Definition: b2Math.h:381
float32 alpha0
Definition: b2Math.h:460
void SetIdentity()
Set this to the identity matrix.
Definition: b2Math.h:271
void Normalize()
Normalize the angles.
Definition: b2Math.h:778
b2Vec3 Solve33(const b2Vec3 &b) const
Definition: b2Math.cpp:25
void SetZero()
Set this matrix to all zeros.
Definition: b2Math.h:278
A 2D column vector.
Definition: b2Math.h:56
void Advance(float32 alpha)
Definition: b2Math.h:768
float32 LengthSquared() const
Definition: b2Math.h:111
void operator*=(float32 a)
Multiply this vector by a scalar.
Definition: b2Math.h:98
void Set(float32 angle)
Set using an angle in radians.
Definition: b2Math.h:373
b2Transform(const b2Vec2 &position, const b2Rot &rotation)
Initialize using a position vector and a rotation.
Definition: b2Math.h:417
void SetZero()
Set this matrix to all zeros.
Definition: b2Math.h:332
b2Mat22(float32 a11, float32 a12, float32 a21, float32 a22)
Construct this matrix using scalars.
Definition: b2Math.h:257
Rotation.
Definition: b2Math.h:360
float32 operator()(int32 i) const
Read from and indexed element.
Definition: b2Math.h:74