86 for (
int32 i = 0; i < count; ++i)
93 const float32 inv3 = 1.0f / 3.0f;
95 for (
int32 i = 0; i < count; ++i)
100 b2Vec2 p3 = i + 1 < count ? vs[i+1] : vs[0];
107 float32 triangleArea = 0.5f * D;
108 area += triangleArea;
111 c += triangleArea * inv3 * (p1 + p2 + p3);
134 for (
int32 i = 0; i < n; ++i)
139 for (
int32 j = 0; j < tempCount; ++j)
169 for (
int32 i = 1; i < n; ++i)
172 if (x > x0 || (x == x0 && ps[i].
y < ps[i0].
y))
188 for (
int32 j = 1; j < n; ++j)
196 b2Vec2 r = ps[ie] - ps[hull[m]];
197 b2Vec2 v = ps[j] - ps[hull[m]];
231 for (
int32 i = 0; i < m; ++i)
237 for (
int32 i = 0; i < m; ++i)
240 int32 i2 = i + 1 < m ? i + 1 : 0;
244 m_normals[i].Normalize();
289 if (denominator == 0.0
f)
291 if (numerator < 0.0
f)
302 if (denominator < 0.0
f && numerator < lower * denominator)
306 lower = numerator / denominator;
309 else if (denominator > 0.0
f && numerator < upper * denominator)
313 upper = numerator / denominator;
349 lower =
b2Min(lower, v);
350 upper =
b2Max(upper, v);
401 const float32 k_inv3 = 1.0f / 3.0f;
411 float32 triangleArea = 0.5f * D;
412 area += triangleArea;
415 center += triangleArea * k_inv3 * (e1 + e2);
420 float32 intx2 = ex1*ex1 + ex2*ex1 + ex2*ex2;
421 float32 inty2 = ey1*ey1 + ey2*ey1 + ey2*ey2;
423 I += (0.25f * k_inv3 * D) * (intx2 + inty2);
427 massData->
mass = density * area;
431 center *= 1.0f / area;
432 massData->
center = center + s;
435 massData->
I = density * I;
446 int32 i2 = i < m_count - 1 ? i1 + 1 : 0;
452 if (j == i1 || j == i2)
float32 b2Dot(const b2Vec2 &a, const b2Vec2 &b)
Perform the dot product on two vectors.
GLint GLint GLint GLint GLint GLint y
b2Vec2 b2Mul(const b2Mat22 &A, const b2Vec2 &v)
b2Vec2 lowerBound
the lower vertex
int32 GetChildCount() const
GLenum GLenum GLenum input
float32 I
The rotational inertia of the shape about the local origin.
bool RayCast(b2RayCastOutput *output, const b2RayCastInput &input, const b2Transform &transform, int32 childIndex) const
Implement b2Shape.
float32 LengthSquared() const
b2Vec2 center
The position of the shape's centroid relative to the shape's origin.
void SetZero()
Set this vector to all zeros.
float32 b2Cross(const b2Vec2 &a, const b2Vec2 &b)
Perform the cross product on two vectors. In 2D this produces a scalar.
void ComputeMass(b2MassData *massData, float32 density) const
float32 mass
The mass of the shape, usually in kilograms.
void * Allocate(int32 size)
Allocate memory. This will use b2Alloc if the size is larger than b2_maxBlockSize.
float32 b2DistanceSquared(const b2Vec2 &a, const b2Vec2 &b)
INT32 INT32 * denominator
b2Shape * Clone(b2BlockAllocator *allocator) const
Implement b2Shape.
bool TestPoint(const b2Transform &transform, const b2Vec2 &p) const
GLint GLint GLint GLint GLint x
b2Vec2 m_vertices[b2_maxPolygonVertices]
#define b2_maxPolygonVertices
void SetAsBox(float32 hx, float32 hy)
b2Vec2 b2MulT(const b2Mat22 &A, const b2Vec2 &v)
An axis aligned bounding box.
void Set(const b2Vec2 *points, int32 count)
void ComputeAABB(b2AABB *aabb, const b2Transform &transform, int32 childIndex) const
void Set(float32 angle)
Set using an angle in radians.
GLdouble GLdouble GLdouble r
GLuint GLuint GLsizei count
void Set(float32 x_, float32 y_)
Set this vector to some specified coordinates.
This holds the mass data computed for a shape.
b2Vec2 m_normals[b2_maxPolygonVertices]
static b2Vec2 ComputeCentroid(const b2Vec2 *vs, int32 count)
b2Vec2 upperBound
the upper vertex
GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble f