本文整理汇总了Java中org.jbox2d.dynamics.contacts.ContactVelocityConstraint.VelocityConstraintPoint类的典型用法代码示例。如果您正苦于以下问题:Java VelocityConstraintPoint类的具体用法?Java VelocityConstraintPoint怎么用?Java VelocityConstraintPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VelocityConstraintPoint类属于org.jbox2d.dynamics.contacts.ContactVelocityConstraint包,在下文中一共展示了VelocityConstraintPoint类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: warmStart
import org.jbox2d.dynamics.contacts.ContactVelocityConstraint.VelocityConstraintPoint; //导入依赖的package包/类
public void warmStart() {
// Warm start.
for (int i = 0; i < m_count; ++i) {
final ContactVelocityConstraint vc = m_velocityConstraints[i];
int indexA = vc.indexA;
int indexB = vc.indexB;
float mA = vc.invMassA;
float iA = vc.invIA;
float mB = vc.invMassB;
float iB = vc.invIB;
int pointCount = vc.pointCount;
Vec2 vA = m_velocities[indexA].v;
float wA = m_velocities[indexA].w;
Vec2 vB = m_velocities[indexB].v;
float wB = m_velocities[indexB].w;
Vec2 normal = vc.normal;
float tangentx = 1.0f * normal.y;
float tangenty = -1.0f * normal.x;
for (int j = 0; j < pointCount; ++j) {
VelocityConstraintPoint vcp = vc.points[j];
float Px = tangentx * vcp.tangentImpulse + normal.x * vcp.normalImpulse;
float Py = tangenty * vcp.tangentImpulse + normal.y * vcp.normalImpulse;
wA -= iA * (vcp.rA.x * Py - vcp.rA.y * Px);
vA.x -= Px * mA;
vA.y -= Py * mA;
wB += iB * (vcp.rB.x * Py - vcp.rB.y * Px);
vB.x += Px * mB;
vB.y += Py * mB;
}
m_velocities[indexA].w = wA;
m_velocities[indexB].w = wB;
}
}
示例2: warmStart
import org.jbox2d.dynamics.contacts.ContactVelocityConstraint.VelocityConstraintPoint; //导入依赖的package包/类
public void warmStart() {
// Warm start.
for (int i = 0; i < m_count; ++i) {
final ContactVelocityConstraint vc = m_velocityConstraints[i];
int indexA = vc.indexA;
int indexB = vc.indexB;
float mA = vc.invMassA;
float iA = vc.invIA;
float mB = vc.invMassB;
float iB = vc.invIB;
int pointCount = vc.pointCount;
Vector2 vA = m_velocities[indexA].v;
float wA = m_velocities[indexA].w;
Vector2 vB = m_velocities[indexB].v;
float wB = m_velocities[indexB].w;
Vector2 normal = vc.normal;
float tangentx = 1.0f * normal.y;
float tangenty = -1.0f * normal.x;
for (int j = 0; j < pointCount; ++j) {
VelocityConstraintPoint vcp = vc.points[j];
float Px = tangentx * vcp.tangentImpulse + normal.x * vcp.normalImpulse;
float Py = tangenty * vcp.tangentImpulse + normal.y * vcp.normalImpulse;
wA -= iA * (vcp.rA.x * Py - vcp.rA.y * Px);
vA.x -= Px * mA;
vA.y -= Py * mA;
wB += iB * (vcp.rB.x * Py - vcp.rB.y * Px);
vB.x += Px * mB;
vB.y += Py * mB;
}
m_velocities[indexA].w = wA;
m_velocities[indexB].w = wB;
}
}