Box2D  2.4.0
A 2D physics engine for games
b2_math.h
1 // MIT License
2 
3 // Copyright (c) 2019 Erin Catto
4 
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 #ifndef B2_MATH_H
24 #define B2_MATH_H
25 
26 #include "b2_settings.h"
27 #include <math.h>
28 
30 inline bool b2IsValid(float x)
31 {
32  return isfinite(x);
33 }
34 
35 #define b2Sqrt(x) sqrtf(x)
36 #define b2Atan2(y, x) atan2f(y, x)
37 
39 struct b2Vec2
40 {
42  b2Vec2() {}
43 
45  b2Vec2(float xIn, float yIn) : x(xIn), y(yIn) {}
46 
48  void SetZero() { x = 0.0f; y = 0.0f; }
49 
51  void Set(float x_, float y_) { x = x_; y = y_; }
52 
54  b2Vec2 operator -() const { b2Vec2 v; v.Set(-x, -y); return v; }
55 
57  float operator () (int32 i) const
58  {
59  return (&x)[i];
60  }
61 
63  float& operator () (int32 i)
64  {
65  return (&x)[i];
66  }
67 
69  void operator += (const b2Vec2& v)
70  {
71  x += v.x; y += v.y;
72  }
73 
75  void operator -= (const b2Vec2& v)
76  {
77  x -= v.x; y -= v.y;
78  }
79 
81  void operator *= (float a)
82  {
83  x *= a; y *= a;
84  }
85 
87  float Length() const
88  {
89  return b2Sqrt(x * x + y * y);
90  }
91 
94  float LengthSquared() const
95  {
96  return x * x + y * y;
97  }
98 
100  float Normalize()
101  {
102  float length = Length();
103  if (length < b2_epsilon)
104  {
105  return 0.0f;
106  }
107  float invLength = 1.0f / length;
108  x *= invLength;
109  y *= invLength;
110 
111  return length;
112  }
113 
115  bool IsValid() const
116  {
117  return b2IsValid(x) && b2IsValid(y);
118  }
119 
121  b2Vec2 Skew() const
122  {
123  return b2Vec2(-y, x);
124  }
125 
126  float x, y;
127 };
128 
130 struct b2Vec3
131 {
133  b2Vec3() {}
134 
136  b2Vec3(float xIn, float yIn, float zIn) : x(xIn), y(yIn), z(zIn) {}
137 
139  void SetZero() { x = 0.0f; y = 0.0f; z = 0.0f; }
140 
142  void Set(float x_, float y_, float z_) { x = x_; y = y_; z = z_; }
143 
145  b2Vec3 operator -() const { b2Vec3 v; v.Set(-x, -y, -z); return v; }
146 
148  void operator += (const b2Vec3& v)
149  {
150  x += v.x; y += v.y; z += v.z;
151  }
152 
154  void operator -= (const b2Vec3& v)
155  {
156  x -= v.x; y -= v.y; z -= v.z;
157  }
158 
160  void operator *= (float s)
161  {
162  x *= s; y *= s; z *= s;
163  }
164 
165  float x, y, z;
166 };
167 
169 struct b2Mat22
170 {
172  b2Mat22() {}
173 
175  b2Mat22(const b2Vec2& c1, const b2Vec2& c2)
176  {
177  ex = c1;
178  ey = c2;
179  }
180 
182  b2Mat22(float a11, float a12, float a21, float a22)
183  {
184  ex.x = a11; ex.y = a21;
185  ey.x = a12; ey.y = a22;
186  }
187 
189  void Set(const b2Vec2& c1, const b2Vec2& c2)
190  {
191  ex = c1;
192  ey = c2;
193  }
194 
196  void SetIdentity()
197  {
198  ex.x = 1.0f; ey.x = 0.0f;
199  ex.y = 0.0f; ey.y = 1.0f;
200  }
201 
203  void SetZero()
204  {
205  ex.x = 0.0f; ey.x = 0.0f;
206  ex.y = 0.0f; ey.y = 0.0f;
207  }
208 
209  b2Mat22 GetInverse() const
210  {
211  float a = ex.x, b = ey.x, c = ex.y, d = ey.y;
212  b2Mat22 B;
213  float det = a * d - b * c;
214  if (det != 0.0f)
215  {
216  det = 1.0f / det;
217  }
218  B.ex.x = det * d; B.ey.x = -det * b;
219  B.ex.y = -det * c; B.ey.y = det * a;
220  return B;
221  }
222 
225  b2Vec2 Solve(const b2Vec2& b) const
226  {
227  float a11 = ex.x, a12 = ey.x, a21 = ex.y, a22 = ey.y;
228  float det = a11 * a22 - a12 * a21;
229  if (det != 0.0f)
230  {
231  det = 1.0f / det;
232  }
233  b2Vec2 x;
234  x.x = det * (a22 * b.x - a12 * b.y);
235  x.y = det * (a11 * b.y - a21 * b.x);
236  return x;
237  }
238 
239  b2Vec2 ex, ey;
240 };
241 
243 struct b2Mat33
244 {
246  b2Mat33() {}
247 
249  b2Mat33(const b2Vec3& c1, const b2Vec3& c2, const b2Vec3& c3)
250  {
251  ex = c1;
252  ey = c2;
253  ez = c3;
254  }
255 
257  void SetZero()
258  {
259  ex.SetZero();
260  ey.SetZero();
261  ez.SetZero();
262  }
263 
266  b2Vec3 Solve33(const b2Vec3& b) const;
267 
271  b2Vec2 Solve22(const b2Vec2& b) const;
272 
275  void GetInverse22(b2Mat33* M) const;
276 
279  void GetSymInverse33(b2Mat33* M) const;
280 
281  b2Vec3 ex, ey, ez;
282 };
283 
285 struct b2Rot
286 {
287  b2Rot() {}
288 
290  explicit b2Rot(float angle)
291  {
293  s = sinf(angle);
294  c = cosf(angle);
295  }
296 
298  void Set(float angle)
299  {
301  s = sinf(angle);
302  c = cosf(angle);
303  }
304 
306  void SetIdentity()
307  {
308  s = 0.0f;
309  c = 1.0f;
310  }
311 
313  float GetAngle() const
314  {
315  return b2Atan2(s, c);
316  }
317 
319  b2Vec2 GetXAxis() const
320  {
321  return b2Vec2(c, s);
322  }
323 
325  b2Vec2 GetYAxis() const
326  {
327  return b2Vec2(-s, c);
328  }
329 
331  float s, c;
332 };
333 
337 {
340 
342  b2Transform(const b2Vec2& position, const b2Rot& rotation) : p(position), q(rotation) {}
343 
345  void SetIdentity()
346  {
347  p.SetZero();
348  q.SetIdentity();
349  }
350 
352  void Set(const b2Vec2& position, float angle)
353  {
354  p = position;
355  q.Set(angle);
356  }
357 
358  b2Vec2 p;
359  b2Rot q;
360 };
361 
366 struct b2Sweep
367 {
371  void GetTransform(b2Transform* transform, float beta) const;
372 
375  void Advance(float alpha);
376 
378  void Normalize();
379 
381  b2Vec2 c0, c;
382  float a0, a;
383 
386  float alpha0;
387 };
388 
390 extern const b2Vec2 b2Vec2_zero;
391 
393 inline float b2Dot(const b2Vec2& a, const b2Vec2& b)
394 {
395  return a.x * b.x + a.y * b.y;
396 }
397 
399 inline float b2Cross(const b2Vec2& a, const b2Vec2& b)
400 {
401  return a.x * b.y - a.y * b.x;
402 }
403 
406 inline b2Vec2 b2Cross(const b2Vec2& a, float s)
407 {
408  return b2Vec2(s * a.y, -s * a.x);
409 }
410 
413 inline b2Vec2 b2Cross(float s, const b2Vec2& a)
414 {
415  return b2Vec2(-s * a.y, s * a.x);
416 }
417 
420 inline b2Vec2 b2Mul(const b2Mat22& A, const b2Vec2& v)
421 {
422  return b2Vec2(A.ex.x * v.x + A.ey.x * v.y, A.ex.y * v.x + A.ey.y * v.y);
423 }
424 
427 inline b2Vec2 b2MulT(const b2Mat22& A, const b2Vec2& v)
428 {
429  return b2Vec2(b2Dot(v, A.ex), b2Dot(v, A.ey));
430 }
431 
433 inline b2Vec2 operator + (const b2Vec2& a, const b2Vec2& b)
434 {
435  return b2Vec2(a.x + b.x, a.y + b.y);
436 }
437 
439 inline b2Vec2 operator - (const b2Vec2& a, const b2Vec2& b)
440 {
441  return b2Vec2(a.x - b.x, a.y - b.y);
442 }
443 
444 inline b2Vec2 operator * (float s, const b2Vec2& a)
445 {
446  return b2Vec2(s * a.x, s * a.y);
447 }
448 
449 inline bool operator == (const b2Vec2& a, const b2Vec2& b)
450 {
451  return a.x == b.x && a.y == b.y;
452 }
453 
454 inline bool operator != (const b2Vec2& a, const b2Vec2& b)
455 {
456  return a.x != b.x || a.y != b.y;
457 }
458 
459 inline float b2Distance(const b2Vec2& a, const b2Vec2& b)
460 {
461  b2Vec2 c = a - b;
462  return c.Length();
463 }
464 
465 inline float b2DistanceSquared(const b2Vec2& a, const b2Vec2& b)
466 {
467  b2Vec2 c = a - b;
468  return b2Dot(c, c);
469 }
470 
471 inline b2Vec3 operator * (float s, const b2Vec3& a)
472 {
473  return b2Vec3(s * a.x, s * a.y, s * a.z);
474 }
475 
477 inline b2Vec3 operator + (const b2Vec3& a, const b2Vec3& b)
478 {
479  return b2Vec3(a.x + b.x, a.y + b.y, a.z + b.z);
480 }
481 
483 inline b2Vec3 operator - (const b2Vec3& a, const b2Vec3& b)
484 {
485  return b2Vec3(a.x - b.x, a.y - b.y, a.z - b.z);
486 }
487 
489 inline float b2Dot(const b2Vec3& a, const b2Vec3& b)
490 {
491  return a.x * b.x + a.y * b.y + a.z * b.z;
492 }
493 
495 inline b2Vec3 b2Cross(const b2Vec3& a, const b2Vec3& b)
496 {
497  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);
498 }
499 
500 inline b2Mat22 operator + (const b2Mat22& A, const b2Mat22& B)
501 {
502  return b2Mat22(A.ex + B.ex, A.ey + B.ey);
503 }
504 
505 // A * B
506 inline b2Mat22 b2Mul(const b2Mat22& A, const b2Mat22& B)
507 {
508  return b2Mat22(b2Mul(A, B.ex), b2Mul(A, B.ey));
509 }
510 
511 // A^T * B
512 inline b2Mat22 b2MulT(const b2Mat22& A, const b2Mat22& B)
513 {
514  b2Vec2 c1(b2Dot(A.ex, B.ex), b2Dot(A.ey, B.ex));
515  b2Vec2 c2(b2Dot(A.ex, B.ey), b2Dot(A.ey, B.ey));
516  return b2Mat22(c1, c2);
517 }
518 
520 inline b2Vec3 b2Mul(const b2Mat33& A, const b2Vec3& v)
521 {
522  return v.x * A.ex + v.y * A.ey + v.z * A.ez;
523 }
524 
526 inline b2Vec2 b2Mul22(const b2Mat33& A, const b2Vec2& v)
527 {
528  return b2Vec2(A.ex.x * v.x + A.ey.x * v.y, A.ex.y * v.x + A.ey.y * v.y);
529 }
530 
532 inline b2Rot b2Mul(const b2Rot& q, const b2Rot& r)
533 {
534  // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc]
535  // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc]
536  // s = qs * rc + qc * rs
537  // c = qc * rc - qs * rs
538  b2Rot qr;
539  qr.s = q.s * r.c + q.c * r.s;
540  qr.c = q.c * r.c - q.s * r.s;
541  return qr;
542 }
543 
545 inline b2Rot b2MulT(const b2Rot& q, const b2Rot& r)
546 {
547  // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc]
548  // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc]
549  // s = qc * rs - qs * rc
550  // c = qc * rc + qs * rs
551  b2Rot qr;
552  qr.s = q.c * r.s - q.s * r.c;
553  qr.c = q.c * r.c + q.s * r.s;
554  return qr;
555 }
556 
558 inline b2Vec2 b2Mul(const b2Rot& q, const b2Vec2& v)
559 {
560  return b2Vec2(q.c * v.x - q.s * v.y, q.s * v.x + q.c * v.y);
561 }
562 
564 inline b2Vec2 b2MulT(const b2Rot& q, const b2Vec2& v)
565 {
566  return b2Vec2(q.c * v.x + q.s * v.y, -q.s * v.x + q.c * v.y);
567 }
568 
569 inline b2Vec2 b2Mul(const b2Transform& T, const b2Vec2& v)
570 {
571  float x = (T.q.c * v.x - T.q.s * v.y) + T.p.x;
572  float y = (T.q.s * v.x + T.q.c * v.y) + T.p.y;
573 
574  return b2Vec2(x, y);
575 }
576 
577 inline b2Vec2 b2MulT(const b2Transform& T, const b2Vec2& v)
578 {
579  float px = v.x - T.p.x;
580  float py = v.y - T.p.y;
581  float x = (T.q.c * px + T.q.s * py);
582  float y = (-T.q.s * px + T.q.c * py);
583 
584  return b2Vec2(x, y);
585 }
586 
587 // v2 = A.q.Rot(B.q.Rot(v1) + B.p) + A.p
588 // = (A.q * B.q).Rot(v1) + A.q.Rot(B.p) + A.p
589 inline b2Transform b2Mul(const b2Transform& A, const b2Transform& B)
590 {
591  b2Transform C;
592  C.q = b2Mul(A.q, B.q);
593  C.p = b2Mul(A.q, B.p) + A.p;
594  return C;
595 }
596 
597 // v2 = A.q' * (B.q * v1 + B.p - A.p)
598 // = A.q' * B.q * v1 + A.q' * (B.p - A.p)
599 inline b2Transform b2MulT(const b2Transform& A, const b2Transform& B)
600 {
601  b2Transform C;
602  C.q = b2MulT(A.q, B.q);
603  C.p = b2MulT(A.q, B.p - A.p);
604  return C;
605 }
606 
607 template <typename T>
608 inline T b2Abs(T a)
609 {
610  return a > T(0) ? a : -a;
611 }
612 
613 inline b2Vec2 b2Abs(const b2Vec2& a)
614 {
615  return b2Vec2(b2Abs(a.x), b2Abs(a.y));
616 }
617 
618 inline b2Mat22 b2Abs(const b2Mat22& A)
619 {
620  return b2Mat22(b2Abs(A.ex), b2Abs(A.ey));
621 }
622 
623 template <typename T>
624 inline T b2Min(T a, T b)
625 {
626  return a < b ? a : b;
627 }
628 
629 inline b2Vec2 b2Min(const b2Vec2& a, const b2Vec2& b)
630 {
631  return b2Vec2(b2Min(a.x, b.x), b2Min(a.y, b.y));
632 }
633 
634 template <typename T>
635 inline T b2Max(T a, T b)
636 {
637  return a > b ? a : b;
638 }
639 
640 inline b2Vec2 b2Max(const b2Vec2& a, const b2Vec2& b)
641 {
642  return b2Vec2(b2Max(a.x, b.x), b2Max(a.y, b.y));
643 }
644 
645 template <typename T>
646 inline T b2Clamp(T a, T low, T high)
647 {
648  return b2Max(low, b2Min(a, high));
649 }
650 
651 inline b2Vec2 b2Clamp(const b2Vec2& a, const b2Vec2& low, const b2Vec2& high)
652 {
653  return b2Max(low, b2Min(a, high));
654 }
655 
656 template<typename T> inline void b2Swap(T& a, T& b)
657 {
658  T tmp = a;
659  a = b;
660  b = tmp;
661 }
662 
668 inline uint32 b2NextPowerOfTwo(uint32 x)
669 {
670  x |= (x >> 1);
671  x |= (x >> 2);
672  x |= (x >> 4);
673  x |= (x >> 8);
674  x |= (x >> 16);
675  return x + 1;
676 }
677 
678 inline bool b2IsPowerOfTwo(uint32 x)
679 {
680  bool result = x > 0 && (x & (x - 1)) == 0;
681  return result;
682 }
683 
684 inline void b2Sweep::GetTransform(b2Transform* xf, float beta) const
685 {
686  xf->p = (1.0f - beta) * c0 + beta * c;
687  float angle = (1.0f - beta) * a0 + beta * a;
688  xf->q.Set(angle);
689 
690  // Shift to origin
691  xf->p -= b2Mul(xf->q, localCenter);
692 }
693 
694 inline void b2Sweep::Advance(float alpha)
695 {
696  b2Assert(alpha0 < 1.0f);
697  float beta = (alpha - alpha0) / (1.0f - alpha0);
698  c0 += beta * (c - c0);
699  a0 += beta * (a - a0);
700  alpha0 = alpha;
701 }
702 
704 inline void b2Sweep::Normalize()
705 {
706  float twoPi = 2.0f * b2_pi;
707  float d = twoPi * floorf(a0 / twoPi);
708  a0 -= d;
709  a -= d;
710 }
711 
712 #endif
b2Rot::GetXAxis
b2Vec2 GetXAxis() const
Get the x-axis.
Definition: b2_math.h:319
b2Vec2
A 2D column vector.
Definition: b2_math.h:39
b2Mat22::b2Mat22
b2Mat22(const b2Vec2 &c1, const b2Vec2 &c2)
Construct this matrix using columns.
Definition: b2_math.h:175
b2Mat33::GetInverse22
void GetInverse22(b2Mat33 *M) const
b2_settings.h
b2Transform::Set
void Set(const b2Vec2 &position, float angle)
Set this based on the position and angle.
Definition: b2_math.h:352
b2Rot::b2Rot
b2Rot(float angle)
Initialize from an angle in radians.
Definition: b2_math.h:290
b2Sweep::alpha0
float alpha0
Definition: b2_math.h:386
b2Vec3::operator+=
void operator+=(const b2Vec3 &v)
Add a vector to this vector.
Definition: b2_math.h:148
b2Mat22::Solve
b2Vec2 Solve(const b2Vec2 &b) const
Definition: b2_math.h:225
b2Vec2::operator-=
void operator-=(const b2Vec2 &v)
Subtract a vector from this vector.
Definition: b2_math.h:75
b2Vec3::operator-=
void operator-=(const b2Vec3 &v)
Subtract a vector from this vector.
Definition: b2_math.h:154
b2Mat33::SetZero
void SetZero()
Set this matrix to all zeros.
Definition: b2_math.h:257
b2Transform
Definition: b2_math.h:336
b2Transform::b2Transform
b2Transform(const b2Vec2 &position, const b2Rot &rotation)
Initialize using a position vector and a rotation.
Definition: b2_math.h:342
b2Vec3
A 2D column vector with 3 elements.
Definition: b2_math.h:130
b2Sweep
Definition: b2_math.h:366
b2Mat33
A 3-by-3 matrix. Stored in column-major order.
Definition: b2_math.h:243
b2Vec2::operator-
b2Vec2 operator-() const
Negate this vector.
Definition: b2_math.h:54
b2Sweep::c
b2Vec2 c
center world positions
Definition: b2_math.h:381
b2Mat22::Set
void Set(const b2Vec2 &c1, const b2Vec2 &c2)
Initialize this matrix using columns.
Definition: b2_math.h:189
b2Mat33::b2Mat33
b2Mat33()
The default constructor does nothing (for performance).
Definition: b2_math.h:246
b2Rot
Rotation.
Definition: b2_math.h:285
b2Vec2::Set
void Set(float x_, float y_)
Set this vector to some specified coordinates.
Definition: b2_math.h:51
b2Vec3::Set
void Set(float x_, float y_, float z_)
Set this vector to some specified coordinates.
Definition: b2_math.h:142
b2Vec2::Normalize
float Normalize()
Convert this vector into a unit vector. Returns the length.
Definition: b2_math.h:100
b2Sweep::GetTransform
void GetTransform(b2Transform *transform, float beta) const
Definition: b2_math.h:684
b2Vec3::b2Vec3
b2Vec3()
Default constructor does nothing (for performance).
Definition: b2_math.h:133
b2Mat22::SetIdentity
void SetIdentity()
Set this to the identity matrix.
Definition: b2_math.h:196
b2Transform::SetIdentity
void SetIdentity()
Set this to the identity transform.
Definition: b2_math.h:345
b2Vec3::b2Vec3
b2Vec3(float xIn, float yIn, float zIn)
Construct using coordinates.
Definition: b2_math.h:136
b2Rot::SetIdentity
void SetIdentity()
Set to the identity rotation.
Definition: b2_math.h:306
b2Sweep::Advance
void Advance(float alpha)
Definition: b2_math.h:694
b2Mat22::b2Mat22
b2Mat22(float a11, float a12, float a21, float a22)
Construct this matrix using scalars.
Definition: b2_math.h:182
b2Vec3::operator-
b2Vec3 operator-() const
Negate this vector.
Definition: b2_math.h:145
b2Vec2::Length
float Length() const
Get the length of this vector (the norm).
Definition: b2_math.h:87
b2Mat33::Solve33
b2Vec3 Solve33(const b2Vec3 &b) const
b2Vec2::b2Vec2
b2Vec2()
Default constructor does nothing (for performance).
Definition: b2_math.h:42
b2Vec3::operator*=
void operator*=(float s)
Multiply this vector by a scalar.
Definition: b2_math.h:160
b2Mat22
A 2-by-2 matrix. Stored in column-major order.
Definition: b2_math.h:169
b2Transform::b2Transform
b2Transform()
The default constructor does nothing.
Definition: b2_math.h:339
b2Rot::Set
void Set(float angle)
Set using an angle in radians.
Definition: b2_math.h:298
b2Vec2::SetZero
void SetZero()
Set this vector to all zeros.
Definition: b2_math.h:48
b2Vec2::b2Vec2
b2Vec2(float xIn, float yIn)
Construct using coordinates.
Definition: b2_math.h:45
b2Vec2::LengthSquared
float LengthSquared() const
Definition: b2_math.h:94
b2Mat33::b2Mat33
b2Mat33(const b2Vec3 &c1, const b2Vec3 &c2, const b2Vec3 &c3)
Construct this matrix using columns.
Definition: b2_math.h:249
b2Vec3::SetZero
void SetZero()
Set this vector to all zeros.
Definition: b2_math.h:139
b2Rot::GetAngle
float GetAngle() const
Get the angle in radians.
Definition: b2_math.h:313
b2Rot::s
float s
Sine and cosine.
Definition: b2_math.h:331
b2Vec2::operator+=
void operator+=(const b2Vec2 &v)
Add a vector to this vector.
Definition: b2_math.h:69
b2Vec2::operator()
float operator()(int32 i) const
Read from and indexed element.
Definition: b2_math.h:57
b2Mat22::b2Mat22
b2Mat22()
The default constructor does nothing (for performance).
Definition: b2_math.h:172
b2Sweep::localCenter
b2Vec2 localCenter
local center of mass position
Definition: b2_math.h:380
b2Sweep::Normalize
void Normalize()
Normalize the angles.
Definition: b2_math.h:704
b2Mat22::SetZero
void SetZero()
Set this matrix to all zeros.
Definition: b2_math.h:203
b2Mat33::Solve22
b2Vec2 Solve22(const b2Vec2 &b) const
b2Mat33::GetSymInverse33
void GetSymInverse33(b2Mat33 *M) const
b2Vec2::operator*=
void operator*=(float a)
Multiply this vector by a scalar.
Definition: b2_math.h:81
b2Vec2::Skew
b2Vec2 Skew() const
Get the skew vector such that dot(skew_vec, other) == cross(vec, other)
Definition: b2_math.h:121
b2Sweep::a
float a
world angles
Definition: b2_math.h:382
b2Rot::GetYAxis
b2Vec2 GetYAxis() const
Get the u-axis.
Definition: b2_math.h:325
b2Vec2::IsValid
bool IsValid() const
Does this vector contain finite coordinates?
Definition: b2_math.h:115