Go to the documentation of this file.
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;
424 return b2Vec2(
A.ex.x * v.
x +
A.ey.x * v.
y,
A.ex.y * v.
x +
A.ey.y * v.
y);
453 return a.
x == b.
x && a.
y == b.
y;
458 return a.
x != b.
x || a.
y != b.
y;
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;
530 return b2Vec2(
A.ex.x * v.
x +
A.ey.x * v.
y,
A.ex.y * v.
x +
A.ey.y * v.
y);
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;
701 c0 += beta * (
c -
c0);
702 a0 += beta * (
a -
a0);
709 float twoPi = 2.0f *
b2_pi;
710 float d = twoPi * floorf(
a0 / twoPi);
b2Rot(float angle)
Initialize from an angle in radians.
float b2Cross(const b2Vec2 &a, const b2Vec2 &b)
Perform the cross product on two vectors. In 2D this produces a scalar.
void Set(float angle)
Set using an angle in radians.
b2Mat22(const b2Vec2 &c1, const b2Vec2 &c2)
Construct this matrix using columns.
b2Vec2(float xIn, float yIn)
Construct using coordinates.
void SetZero()
Set this vector to all zeros.
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
const B2_API b2Vec2 b2Vec2_zero
Useful constant.
void Advance(float alpha)
b2Vec2 b2MulT(const b2Mat22 &A, const b2Vec2 &v)
float GetAngle() const
Get the angle in radians.
b2Vec2 localCenter
local center of mass position
float Normalize()
Convert this vector into a unit vector. Returns the length.
bool operator!=(const b2Vec2 &a, const b2Vec2 &b)
b2Vec3(float xIn, float yIn, float zIn)
Construct using coordinates.
void SetIdentity()
Set to the identity rotation.
void Set(const b2Vec2 &c1, const b2Vec2 &c2)
Initialize this matrix using columns.
A 2D column vector with 3 elements.
A 2-by-2 matrix. Stored in column-major order.
void SetIdentity()
Set this to the identity matrix.
b2Vec2 Skew() const
Get the skew vector such that dot(skew_vec, other) == cross(vec, other)
void GetTransform(b2Transform *transform, float beta) const
b2Vec2()
Default constructor does nothing (for performance).
b2Vec2 GetXAxis() const
Get the x-axis.
void SetZero()
Set this vector to all zeros.
b2Vec2 b2Mul(const b2Mat22 &A, const b2Vec2 &v)
b2Vec3()
Default constructor does nothing (for performance).
b2Mat22(float a11, float a12, float a21, float a22)
Construct this matrix using scalars.
void Set(float x_, float y_)
Set this vector to some specified coordinates.
uint32 b2NextPowerOfTwo(uint32 x)
b2Mat22 GetInverse() const
bool b2IsPowerOfTwo(uint32 x)
T b2Clamp(T a, T low, T high)
b2Vec2 operator*(float s, const b2Vec2 &a)
bool b2IsValid(float x)
This function is used to ensure that a floating point number is not a NaN or infinity.
b2Vec2 Solve(const b2Vec2 &b) const
GLenum GLuint GLenum GLsizei length
void Set(float x_, float y_, float z_)
Set this vector to some specified coordinates.
b2Vec2 operator-(const b2Vec2 &a, const b2Vec2 &b)
Subtract two vectors component-wise.
bool operator==(const b2Vec2 &a, const b2Vec2 &b)
float b2Dot(const b2Vec2 &a, const b2Vec2 &b)
Perform the dot product on two vectors.
b2Vec2 b2Mul22(const b2Mat33 &A, const b2Vec2 &v)
Multiply a matrix times a vector.
float LengthSquared() const
bool IsValid() const
Does this vector contain finite coordinates?
float b2Distance(const b2Vec2 &a, const b2Vec2 &b)
b2Vec2 operator+(const b2Vec2 &a, const b2Vec2 &b)
Add two vectors component-wise.
b2Vec2 GetYAxis() const
Get the u-axis.
b2Mat33(const b2Vec3 &c1, const b2Vec3 &c2, const b2Vec3 &c3)
Construct this matrix using columns.
void SetZero()
Set this matrix to all zeros.
A 3-by-3 matrix. Stored in column-major order.
float b2DistanceSquared(const b2Vec2 &a, const b2Vec2 &b)
b2Mat22()
The default constructor does nothing (for performance).
b2Vec2 c
center world positions
void SetZero()
Set this matrix to all zeros.
void Normalize()
Normalize the angles.
float Length() const
Get the length of this vector (the norm).
b2Mat33()
The default constructor does nothing (for performance).
mvsim
Author(s):
autogenerated on Wed May 28 2025 02:13:07