本文整理汇总了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;
}
}
开发者ID:jfcameron,项目名称:G2Dj,代码行数:39,代码来源:ContactSolver.java
示例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;
}
}
开发者ID:pianoman373,项目名称:Point-Engine,代码行数:39,代码来源:ContactSolver.java
注:本文中的org.jbox2d.dynamics.contacts.ContactVelocityConstraint.VelocityConstraintPoint类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论