/** * Get the supporting vertex in the given direction. * * @param d * @return */ public final Vec2 getSupportVertex(final Vec2 d) { int bestIndex = 0; float bestValue = Vec2.dot(m_vertices[0], d); for (int i = 1; i < m_count; i++) { float value = Vec2.dot(m_vertices[i], d); if (value > bestValue) { bestIndex = i; bestValue = value; } } return m_vertices[bestIndex]; }
/** * Get the supporting vertex index in the given direction. * * @param d * @return */ public final int getSupport(final Vec2 d) { int bestIndex = 0; float bestValue = Vec2.dot(m_vertices[0], d); for (int i = 1; i < m_count; i++) { float value = Vec2.dot(m_vertices[i], d); if (value > bestValue) { bestIndex = i; bestValue = value; } } return bestIndex; }
/** * Multiply another matrix by the transpose of this one (transpose of this one on left). djm: * optimized * * @param B * @return */ public final Mat22 mulTrans(final Mat22 B) { /* * Vec2 c1 = new Vec2(Vec2.dot(this.ex, B.ex), Vec2.dot(this.ey, B.ex)); Vec2 c2 = new * Vec2(Vec2.dot(this.ex, B.ey), Vec2.dot(this.ey, B.ey)); Mat22 C = new Mat22(); C.set(c1, c2); * return C; */ final Mat22 C = new Mat22(); C.ex.x = Vec2.dot(this.ex, B.ex); C.ex.y = Vec2.dot(this.ey, B.ex); C.ey.x = Vec2.dot(this.ex, B.ey); C.ey.y = Vec2.dot(this.ey, B.ey); return C; }
/** * Set the linear velocity of the center of mass. * * @param v the new linear velocity of the center of mass. */ public final void setLinearVelocity(Vec2 v) { if (m_type == BodyType.STATIC) { return; } if (Vec2.dot(v, v) > 0.0f) { setAwake(true); } m_linearVelocity.set(v); }
float Cdot = Vec2.dot(m_ax, temp.set(vB).subLocal(vA)) + m_sBx * wB - m_sAx * wA; float impulse = -m_springMass * (Cdot + m_bias + m_gamma * m_springImpulse); m_springImpulse += impulse; float Cdot = Vec2.dot(m_ay, temp.set(vB).subLocal(vA)) + m_sBy * wB - m_sAy * wA; float impulse = -m_mass * Cdot; m_impulse += impulse;
public float getJointTranslation() { Vec2 pA = pool.popVec2(), pB = pool.popVec2(), axis = pool.popVec2(); m_bodyA.getWorldPointToOut(m_localAnchorA, pA); m_bodyB.getWorldPointToOut(m_localAnchorB, pB); m_bodyA.getWorldVectorToOutUnsafe(m_localXAxisA, axis); pB.subLocal(pA); float translation = Vec2.dot(pB, axis); pool.pushVec2(3); return translation; }
public float getJointTranslation() { Body b1 = m_bodyA; Body b2 = m_bodyB; Vec2 p1 = pool.popVec2(); Vec2 p2 = pool.popVec2(); Vec2 axis = pool.popVec2(); b1.getWorldPointToOut(m_localAnchorA, p1); b2.getWorldPointToOut(m_localAnchorA, p2); p2.subLocal(p1); b1.getWorldVectorToOut(m_localXAxisA, axis); float translation = Vec2.dot(p2, axis); pool.pushVec2(3); return translation; }
Vec2.crossToOutUnsafe(wB, m_rB, vpB); vpB.addLocal(vB); float Cdot = Vec2.dot(m_u, vpB.subLocal(vpA));
Transform.mulToOutUnsafe(xfb, localPointB, pointB); float separation = Vec2.dot(pointB.subLocal(pointA), m_axis); return separation; float separation = Vec2.dot(pointB.subLocal(pointA), normal); return separation; Transform.mulToOutUnsafe(xfa, localPointA, pointA); float separation = Vec2.dot(pointA.subLocal(pointB), normal); return separation;
float Cdot = Vec2.dot(m_u, temp.set(vpB).subLocal(vpA));
Transform.mulToOutUnsafe(xfb, localPointB, pointB); float separation = Vec2.dot(pointB.subLocal(pointA), m_axis); return separation; Transform.mulToOutUnsafe(xfb, localPointB, pointB); float separation = Vec2.dot(pointB.subLocal(pointA), normal); return separation; Transform.mulToOutUnsafe(xfa, localPointA, pointA); float separation = Vec2.dot(pointA.subLocal(pointB), normal); return separation;
m_I = massData.I - m_mass * Vec2.dot(massData.center, massData.center); assert (m_I > 0.0f); m_invI = 1.0f / m_I;
float sBy = Vec2.cross(rB, ay); float C = Vec2.dot(d, ay);