Go to the documentation of this file.
91 const float inv3 = 1.0f / 3.0f;
93 for (
int32 i = 0; i < count; ++i)
98 b2Vec2 p3 = i + 1 < count ? vs[i+1] -
s : vs[0] -
s;
105 float triangleArea = 0.5f * D;
106 area += triangleArea;
109 c += triangleArea * inv3 * (p1 + p2 + p3);
114 c = (1.0f / area) * c +
s;
132 for (
int32 i = 0; i < n; ++i)
137 for (
int32 j = 0; j < tempCount; ++j)
167 for (
int32 i = 1; i < n; ++i)
170 if (x > x0 || (x == x0 && ps[i].y < ps[i0].y))
187 for (
int32 j = 1; j < n; ++j)
195 b2Vec2 r = ps[ie] - ps[hull[m]];
196 b2Vec2 v = ps[j] - ps[hull[m]];
230 for (
int32 i = 0; i < m; ++i)
236 for (
int32 i = 0; i < m; ++i)
239 int32 i2 = i + 1 < m ? i + 1 : 0;
288 if (denominator == 0.0
f)
290 if (numerator < 0.0
f)
301 if (denominator < 0.0
f && numerator < lower * denominator)
305 lower = numerator / denominator;
308 else if (denominator > 0.0
f && numerator < upper * denominator)
312 upper = numerator / denominator;
348 lower =
b2Min(lower, v);
349 upper =
b2Max(upper, v);
393 const float k_inv3 = 1.0f / 3.0f;
403 float triangleArea = 0.5f * D;
404 area += triangleArea;
407 center += triangleArea * k_inv3 * (e1 + e2);
409 float ex1 = e1.
x, ey1 = e1.
y;
410 float ex2 = e2.
x, ey2 = e2.
y;
412 float intx2 = ex1*ex1 + ex2*ex1 + ex2*ex2;
413 float inty2 = ey1*ey1 + ey2*ey1 + ey2*ey2;
415 I += (0.25f * k_inv3 * D) * (intx2 + inty2);
419 massData->
mass = density * area;
423 center *= 1.0f / area;
427 massData->
I = density * I;
444 if (j == i1 || j == i2)
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.
float mass
The mass of the shape, usually in kilograms.
b2Vec2 m_vertices[b2_maxPolygonVertices]
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
b2Vec2 m_normals[b2_maxPolygonVertices]
b2Vec2 b2MulT(const b2Mat22 &A, const b2Vec2 &v)
void * Allocate(int32 size)
Allocate memory. This will use b2Alloc if the size is larger than b2_maxBlockSize.
float Normalize()
Convert this vector into a unit vector. Returns the length.
bool TestPoint(const b2Transform &transform, const b2Vec2 &p) const override
void ComputeMass(b2MassData *massData, float density) const override
void SetZero()
Set this vector to all zeros.
b2Vec2 b2Mul(const b2Mat22 &A, const b2Vec2 &v)
void Set(float x_, float y_)
Set this vector to some specified coordinates.
b2Vec2 upperBound
the upper vertex
b2Shape * Clone(b2BlockAllocator *allocator) const override
Implement b2Shape.
void Set(const b2Vec2 *points, int32 count)
TFSIMD_FORCE_INLINE tfScalar dot(const Quaternion &q1, const Quaternion &q2)
int32 GetChildCount() const override
b2Vec2 center
The position of the shape's centroid relative to the shape's origin.
static b2Vec2 ComputeCentroid(const b2Vec2 *vs, int32 count)
float b2Dot(const b2Vec2 &a, const b2Vec2 &b)
Perform the dot product on two vectors.
void SetAsBox(float hx, float hy)
float LengthSquared() const
void ComputeAABB(b2AABB *aabb, const b2Transform &transform, int32 childIndex) const override
An axis aligned bounding box.
float I
The rotational inertia of the shape about the local origin.
This holds the mass data computed for a shape.
float b2DistanceSquared(const b2Vec2 &a, const b2Vec2 &b)
bool RayCast(b2RayCastOutput *output, const b2RayCastInput &input, const b2Transform &transform, int32 childIndex) const override
b2Vec2 lowerBound
the lower vertex
#define b2_maxPolygonVertices
mvsim
Author(s):
autogenerated on Wed May 28 2025 02:13:07