public Rotation(float angle) { set(angle); }
/** * Get the interpolated transform at a specific time. * * @param xf the result is placed here - must not be null * @param t the normalized time in [0,1]. */ public final void getTransform(final Transform xf, final float beta) { assert (xf != null); // xf->p = (1.0f - beta) * c0 + beta * c; // float32 angle = (1.0f - beta) * a0 + beta * a; // xf->q.Set(angle); xf.p.x = (1.0f - beta) * c0.x + beta * c.x; xf.p.y = (1.0f - beta) * c0.y + beta * c.y; float angle = (1.0f - beta) * a0 + beta * a; xf.q.set(angle); // Shift to origin // xf->p -= b2Mul(xf->q, localCenter); final Rotation q = xf.q; xf.p.x -= q.c * localCenter.x - q.s * localCenter.y; xf.p.y -= q.s * localCenter.x + q.c * localCenter.y; }
/** * Set this based on the position and angle. * * @param p * @param angle */ public final void set(Vec2 p, float angle) { this.p.set(p); q.set(angle); }
/** Set this to equal another transform. */ public final Transform set(final Transform xf) { p.set(xf.p); q.set(xf.q); return this; }
protected final void advance(float t) { // Advance to the new safe time. This doesn't sync the broad-phase. m_sweep.advance(t); m_sweep.c.set(m_sweep.c0); m_sweep.a = m_sweep.a0; m_xf.q.set(m_sweep.a); // m_xf.position = m_sweep.c - Mul(m_xf.R, m_sweep.localCenter); Rotation.mulToOutUnsafe(m_xf.q, m_sweep.localCenter, m_xf.p); m_xf.p.mulLocal(-1).addLocal(m_sweep.c); } }
/** * Set the position of the body's origin and rotation. This breaks any contacts and wakes the * other bodies. Manipulating a body's transform may cause non-physical behavior. Note: contacts * are updated on the next call to World.step(). * * @param position the world position of the body's local origin. * @param angle the world rotation in radians. */ public final void setTransform(Vec2 position, float angle) { world.assertNotLocked(); m_xf.q.set(angle); m_xf.p.set(position); // m_sweep.c0 = m_sweep.c = Mul(m_xf, m_sweep.localCenter); Transform.mulToOutUnsafe(m_xf, m_sweep.localCenter, m_sweep.c); m_sweep.a = angle; m_sweep.c0.set(m_sweep.c); m_sweep.a0 = m_sweep.a; BroadPhase broadPhase = world.m_contactManager.m_broadPhase; for (Fixture f : fixtures) { f.synchronize(broadPhase, m_xf, m_xf); } }
void solveRigid(final TimeStep step) { for (ParticleGroup group = m_groupList; group != null; group = group.getNext()) { if ((group.m_groupFlags & ParticleGroupType.b2_rigidParticleGroup) != 0) { group.updateStatistics(); Vec2 temp = tempVec; Vec2 cross = tempVec2; Rotation rotation = tempRotation; rotation.set(step.dt * group.m_angularVelocity); Rotation.mulToOutUnsafe(rotation, group.m_center, cross); temp.set(group.m_linearVelocity).mulLocal(step.dt).addLocal(group.m_center).subLocal(cross); tempXf.p.set(temp); tempXf.q.set(rotation); Transform.mulToOut(tempXf, group.m_transform, group.m_transform); final Transform velocityTransform = tempXf2; velocityTransform.p.x = step.inv_dt * tempXf.p.x; velocityTransform.p.y = step.inv_dt * tempXf.p.y; velocityTransform.q.s = step.inv_dt * tempXf.q.s; velocityTransform.q.c = step.inv_dt * (tempXf.q.c - 1); for (int i = group.m_firstIndex; i < group.m_lastIndex; i++) { Transform.mulToOutUnsafe(velocityTransform, m_positionBuffer.data[i], m_velocityBuffer.data[i]); } } } }
/** * Build vertices to represent an oriented box. * * @param hx the half-width. * @param hy the half-height. * @param center the center of the box in local coordinates. * @param angle the rotation of the box in local coordinates. */ public final void setAsBox(final float hx, final float hy, final Vec2 center, final float angle) { vertexCount = 4; m_vertices[0].set(-hx, -hy); m_vertices[1].set(hx, -hy); m_vertices[2].set(hx, hy); m_vertices[3].set(-hx, hy); m_normals[0].set(0.0f, -1.0f); m_normals[1].set(1.0f, 0.0f); m_normals[2].set(0.0f, 1.0f); m_normals[3].set(-1.0f, 0.0f); m_centroid.set(center); final Transform xf = poolt1; xf.p.set(center); xf.q.set(angle); // Transform vertices and normals. for (int i = 0; i < vertexCount; ++i) { Transform.mulToOut(xf, m_vertices[i], m_vertices[i]); Rotation.mulToOut(xf.q, m_normals[i], m_normals[i]); } }
m_xf.q.set(bd.getAngle());