37 #define b2Sqrt(x) sqrtf(x) 38 #define b2Atan2(y, x) atan2f(y, x) 47 b2Vec2(
float xIn,
float yIn) : x(xIn), y(yIn) {}
53 void Set(
float x_,
float y_) { x = x_; y = y_; }
59 float operator () (
int32 i)
const 83 void operator *= (
float a)
91 return b2Sqrt(x * x + y * y);
109 float invLength = 1.0f /
length;
138 b2Vec3(
float xIn,
float yIn,
float zIn) : x(xIn), y(yIn), z(zIn) {}
141 void SetZero() { x = 0.0f; y = 0.0f; z = 0.0f; }
144 void Set(
float x_,
float y_,
float z_) { x = x_; y = y_; z = z_; }
152 x += v.
x; y += v.
y; z += v.
z;
158 x -= v.
x; y -= v.
y; z -= v.
z;
162 void operator *= (
float s)
164 x *= s; y *= s; z *= s;
184 b2Mat22(
float a11,
float a12,
float a21,
float a22)
186 ex.x = a11; ex.y = a21;
187 ey.x = a12; ey.y = a22;
200 ex.x = 1.0f; ey.x = 0.0f;
201 ex.y = 0.0f; ey.y = 1.0f;
207 ex.x = 0.0f; ey.x = 0.0f;
208 ex.y = 0.0f; ey.y = 0.0f;
213 float a = ex.x, b = ey.x, c = ex.y,
d = ey.y;
215 float det = a *
d - b * c;
220 B.
ex.
x = det *
d; B.
ey.
x = -det * b;
221 B.
ex.
y = -det * c; B.
ey.
y = det * a;
229 float a11 = ex.
x, a12 = ey.x, a21 = ex.y, a22 = ey.y;
230 float det = a11 * a22 - a12 * a21;
236 x.
x = det * (a22 * b.
x - a12 * b.
y);
237 x.
y = det * (a11 * b.
y - a21 * b.
x);
277 void GetInverse22(
b2Mat33* M)
const;
281 void GetSymInverse33(
b2Mat33* M)
const;
373 void GetTransform(
b2Transform* transform,
float beta)
const;
377 void Advance(
float alpha);
397 return a.
x * b.
x + a.
y * b.
y;
403 return a.
x * b.
y - a.
y * b.
x;
453 return a.
x == b.
x && a.
y == b.
y;
458 return a.
x != b.
x || a.
y != b.
y;
475 return b2Vec3(s * a.
x, s * a.
y, s * a.
z);
493 return a.
x * b.
x + a.
y * b.
y + a.
z * b.
z;
524 return v.
x * A.
ex + v.
y * A.
ey + v.
z * A.
ez;
541 qr.
s = q.
s * r.
c + q.
c * r.
s;
542 qr.
c = q.
c * r.
c - q.
s * r.
s;
554 qr.
s = q.
c * r.
s - q.
s * r.
c;
555 qr.
c = q.
c * r.
c + q.
s * r.
s;
573 float x = (T.
q.
c * v.
x - T.
q.
s * v.
y) + T.
p.
x;
574 float y = (T.
q.
s * v.
x + T.
q.
c * v.
y) + T.
p.
y;
581 float px = v.
x - T.
p.
x;
582 float py = v.
y - T.
p.
y;
583 float x = (T.
q.
c * px + T.
q.
s * py);
584 float y = (-T.
q.
s * px + T.
q.
c * py);
609 template <
typename T>
612 return a > T(0) ? a : -a;
625 template <
typename T>
628 return a < b ? a : b;
636 template <
typename T>
639 return a > b ? a : b;
647 template <
typename T>
658 template<
typename T>
inline void b2Swap(T& a, T& b)
682 bool result = x > 0 && (x & (x - 1)) == 0;
689 xf->
p = (1.0f - beta) * c0 + beta * c;
690 float angle = (1.0f - beta) * a0 + beta * a;
694 xf->
p -=
b2Mul(xf->
q, localCenter);
700 float beta = (alpha - alpha0) / (1.0
f - alpha0);
701 c0 += beta * (c - c0);
702 a0 += beta * (a - a0);
709 float twoPi = 2.0f *
b2_pi;
710 float d = twoPi * floorf(a0 / twoPi);
b2Vec2 b2Mul22(const b2Mat33 &A, const b2Vec2 &v)
Multiply a matrix times a vector.
b2Vec2 b2Mul(const b2Mat22 &A, const b2Vec2 &v)
void SetIdentity()
Set this to the identity matrix.
B2_API const b2Vec2 b2Vec2_zero
Useful constant.
b2Mat33(const b2Vec3 &c1, const b2Vec3 &c2, const b2Vec3 &c3)
Construct this matrix using columns.
b2Vec2 Solve(const b2Vec2 &b) const
float b2Dot(const b2Vec2 &a, const b2Vec2 &b)
Perform the dot product on two vectors.
TF2SIMD_FORCE_INLINE tf2Scalar angle(const Quaternion &q1, const Quaternion &q2)
float Length() const
Get the length of this vector (the norm).
void SetIdentity()
Set to the identity rotation.
void SetZero()
Set this matrix to all zeros.
b2Vec2 operator*(float s, const b2Vec2 &a)
b2Mat33()
The default constructor does nothing (for performance).
GLenum GLuint GLenum GLsizei length
b2Vec2 GetXAxis() const
Get the x-axis.
b2Vec2()
Default constructor does nothing (for performance).
void SetZero()
Set this vector to all zeros.
b2Mat22()
The default constructor does nothing (for performance).
b2Mat22(const b2Vec2 &c1, const b2Vec2 &c2)
Construct this matrix using columns.
float b2DistanceSquared(const b2Vec2 &a, const b2Vec2 &b)
b2Vec2 localCenter
local center of mass position
A 2D column vector with 3 elements.
void SetZero()
Set this vector to all zeros.
b2Mat22 GetInverse() const
b2Vec3()
Default constructor does nothing (for performance).
float b2Distance(const b2Vec2 &a, const b2Vec2 &b)
b2Vec2 operator+(const b2Vec2 &a, const b2Vec2 &b)
Add two vectors component-wise.
float LengthSquared() const
bool IsValid() const
Does this vector contain finite coordinates?
void Set(float x_, float y_)
Set this vector to some specified coordinates.
float b2Cross(const b2Vec2 &a, const b2Vec2 &b)
Perform the cross product on two vectors. In 2D this produces a scalar.
b2Vec2 GetYAxis() const
Get the u-axis.
bool b2IsValid(float x)
This function is used to ensure that a floating point number is not a NaN or infinity.
b2Mat22(float a11, float a12, float a21, float a22)
Construct this matrix using scalars.
bool b2IsPowerOfTwo(uint32 x)
T b2Clamp(T a, T low, T high)
bool operator==(const b2Vec2 &a, const b2Vec2 &b)
A 3-by-3 matrix. Stored in column-major order.
float GetAngle() const
Get the angle in radians.
b2Vec2 Skew() const
Get the skew vector such that dot(skew_vec, other) == cross(vec, other)
b2Rot(float angle)
Initialize from an angle in radians.
void Normalize()
Normalize the angles.
void SetZero()
Set this matrix to all zeros.
b2Vec2 b2MulT(const b2Mat22 &A, const b2Vec2 &v)
b2Vec2(float xIn, float yIn)
Construct using coordinates.
float Normalize()
Convert this vector into a unit vector. Returns the length.
bool operator!=(const b2Vec2 &a, const b2Vec2 &b)
uint32 b2NextPowerOfTwo(uint32 x)
b2Vec3(float xIn, float yIn, float zIn)
Construct using coordinates.
A 2-by-2 matrix. Stored in column-major order.
void Set(const b2Vec2 &c1, const b2Vec2 &c2)
Initialize this matrix using columns.
void Set(float x_, float y_, float z_)
Set this vector to some specified coordinates.
void GetTransform(b2Transform *transform, float beta) const
void Set(float angle)
Set using an angle in radians.
void Advance(float alpha)
b2Vec2 operator-(const b2Vec2 &a, const b2Vec2 &b)
Subtract two vectors component-wise.