本文整理汇总了Java中org.jbox2d.common.Vec3.set方法的典型用法代码示例。如果您正苦于以下问题:Java Vec3.set方法的具体用法?Java Vec3.set怎么用?Java Vec3.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jbox2d.common.Vec3
的用法示例。
在下文中一共展示了Vec3.set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: solveVelocityConstraints
import org.jbox2d.common.Vec3; //导入方法依赖的package包/类
/**
* @see org.jbox2d.dynamics.joints.Joint#solveVelocityConstraints(org.jbox2d.dynamics.TimeStep)
*/
@Override
public void solveVelocityConstraints(TimeStep step) {
Body bA = m_bodyA;
Body bB = m_bodyB;
Vec2 vA = bA.m_linearVelocity;
float wA = bA.m_angularVelocity;
Vec2 vB = bB.m_linearVelocity;
float wB = bB.m_angularVelocity;
float mA = bA.m_invMass, mB = bB.m_invMass;
float iA = bA.m_invI, iB = bB.m_invI;
final Vec2 rA = pool.popVec2();
final Vec2 rB = pool.popVec2();
rA.set(m_localAnchorA).subLocal(bA.getLocalCenter());
rB.set(m_localAnchorB).subLocal(bB.getLocalCenter());
Mat22.mulToOut(bA.getTransform().R, rA, rA);
Mat22.mulToOut(bB.getTransform().R, rB, rB);
final Vec2 Cdot1 = pool.popVec2();
final Vec2 temp = pool.popVec2();
// Solve point-to-point finalraint
Vec2.crossToOut(wA, rA, temp);
Vec2.crossToOut(wB, rB, Cdot1);
Cdot1.addLocal(vB).subLocal(vA).subLocal(temp);
float Cdot2 = wB - wA;
final Vec3 Cdot = pool.popVec3();
Cdot.set(Cdot1.x, Cdot1.y, Cdot2);
final Vec3 impulse = pool.popVec3();
m_mass.solve33ToOut(Cdot.negateLocal(), impulse); // just leave Cdot negated..
m_impulse.addLocal(impulse);
final Vec2 P = pool.popVec2();
P.set(impulse.x, impulse.y);
temp.set(P).mulLocal(mA);
vA.subLocal(temp);
wA -= iA * (Vec2.cross(rA, P) + impulse.z);
temp.set(P).mulLocal(mB);
vB.addLocal(temp);
wB += iB * (Vec2.cross(rB, P) + impulse.z);
bA.m_linearVelocity.set(vA);
bA.m_angularVelocity = wA;
bB.m_linearVelocity.set(vB);
bB.m_angularVelocity = wB;
pool.pushVec2(5);
pool.pushVec3(2);
}
示例2: solvePositionConstraints
import org.jbox2d.common.Vec3; //导入方法依赖的package包/类
/**
* @see org.jbox2d.dynamics.joints.Joint#solvePositionConstraints(float)
*/
@Override
public boolean solvePositionConstraints(float baumgarte) {
Body bA = m_bodyA;
Body bB = m_bodyB;
float mA = bA.m_invMass, mB = bB.m_invMass;
float iA = bA.m_invI, iB = bB.m_invI;
final Vec2 rA = pool.popVec2();
final Vec2 rB = pool.popVec2();
rA.set(m_localAnchorA).subLocal(bA.getLocalCenter());
rB.set(m_localAnchorB).subLocal(bB.getLocalCenter());
Mat22.mulToOut(bA.getTransform().R, rA, rA);
Mat22.mulToOut(bB.getTransform().R, rB, rB);
final Vec2 C1 = pool.popVec2();
C1.set(bB.m_sweep.c).addLocal(rB).subLocal(bA.m_sweep.c).subLocal(rA);
float C2 = bB.m_sweep.a - bA.m_sweep.a - m_referenceAngle;
// Handle large detachment.
final float k_allowedStretch = 10.0f * Settings.linearSlop;
float positionError = C1.length();
float angularError = MathUtils.abs(C2);
if (positionError > k_allowedStretch){
iA *= 1.0f;
iB *= 1.0f;
}
m_mass.col1.x = mA + mB + rA.y * rA.y * iA + rB.y * rB.y * iB;
m_mass.col2.x = -rA.y * rA.x * iA - rB.y * rB.x * iB;
m_mass.col3.x = -rA.y * iA - rB.y * iB;
m_mass.col1.y = m_mass.col2.x;
m_mass.col2.y = mA + mB + rA.x * rA.x * iA + rB.x * rB.x * iB;
m_mass.col3.y = rA.x * iA + rB.x * iB;
m_mass.col1.z = m_mass.col3.x;
m_mass.col2.z = m_mass.col3.y;
m_mass.col3.z = iA + iB;
final Vec3 C = pool.popVec3();
final Vec3 impulse = pool.popVec3();
C.set(C1.x, C1.y, C2);
m_mass.solve33ToOut(C.negateLocal(), impulse); // just leave c negated..
final Vec2 P = pool.popVec2();
final Vec2 temp = pool.popVec2();
P.set(impulse.x, impulse.y);
temp.set(P).mulLocal(mA);
bA.m_sweep.c.subLocal(temp);
bA.m_sweep.a -= iA * (Vec2.cross(rA, P) + impulse.z);
temp.set(P).mulLocal(mB);
bB.m_sweep.c.addLocal(temp);
bB.m_sweep.a += iB * (Vec2.cross(rB, P) + impulse.z);
bA.synchronizeTransform();
bB.synchronizeTransform();
pool.pushVec2(5);
pool.pushVec3(2);
return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;
}