本文整理匯總了Java中org.jbox2d.common.Vec2.set方法的典型用法代碼示例。如果您正苦於以下問題:Java Vec2.set方法的具體用法?Java Vec2.set怎麽用?Java Vec2.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jbox2d.common.Vec2
的用法示例。
在下文中一共展示了Vec2.set方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getClosestPoint
import org.jbox2d.common.Vec2; //導入方法依賴的package包/類
/**
* this returns pooled objects. don't keep or modify them
*
* @return
*/
public void getClosestPoint(final Vec2 out) {
switch (m_count) {
case 0:
assert (false);
out.setZero();
return;
case 1:
out.set(m_v1.w);
return;
case 2:
case22.set(m_v2.w).mulLocal(m_v2.a);
case2.set(m_v1.w).mulLocal(m_v1.a).addLocal(case22);
out.set(case2);
return;
case 3:
out.setZero();
return;
default:
assert (false);
out.setZero();
return;
}
}
示例2: computeCentroidToOut
import org.jbox2d.common.Vec2; //導入方法依賴的package包/類
public final void computeCentroidToOut(final Vec2[] vs, final int count, final Vec2 out) {
assert (count >= 3);
out.set(0.0f, 0.0f);
float area = 0.0f;
// pRef is the reference point for forming triangles.
// It's location doesn't change the result (except for rounding error).
final Vec2 pRef = pool1;
pRef.setZero();
final Vec2 e1 = pool2;
final Vec2 e2 = pool3;
final float inv3 = 1.0f / 3.0f;
for (int i = 0; i < count; ++i) {
// Triangle vertices.
final Vec2 p1 = pRef;
final Vec2 p2 = vs[i];
final Vec2 p3 = i + 1 < count ? vs[i + 1] : vs[0];
e1.set(p2).subLocal(p1);
e2.set(p3).subLocal(p1);
final float D = Vec2.cross(e1, e2);
final float triangleArea = 0.5f * D;
area += triangleArea;
// Area weighted centroid
e1.set(p1).addLocal(p2).addLocal(p3).mulLocal(triangleArea * inv3);
out.addLocal(e1);
}
// Centroid
assert (area > Settings.EPSILON);
out.mulLocal(1.0f / area);
}
示例3: getWitnessPoints
import org.jbox2d.common.Vec2; //導入方法依賴的package包/類
public void getWitnessPoints(Vec2 pA, Vec2 pB) {
switch (m_count) {
case 0:
assert (false);
break;
case 1:
pA.set(m_v1.wA);
pB.set(m_v1.wB);
break;
case 2:
case2.set(m_v1.wA).mulLocal(m_v1.a);
pA.set(m_v2.wA).mulLocal(m_v2.a).addLocal(case2);
// m_v1.a * m_v1.wA + m_v2.a * m_v2.wA;
// *pB = m_v1.a * m_v1.wB + m_v2.a * m_v2.wB;
case2.set(m_v1.wB).mulLocal(m_v1.a);
pB.set(m_v2.wB).mulLocal(m_v2.a).addLocal(case2);
break;
case 3:
pA.set(m_v1.wA).mulLocal(m_v1.a);
case3.set(m_v2.wA).mulLocal(m_v2.a);
case33.set(m_v3.wA).mulLocal(m_v3.a);
pA.addLocal(case3).addLocal(case33);
pB.set(pA);
// *pA = m_v1.a * m_v1.wA + m_v2.a * m_v2.wA + m_v3.a * m_v3.wA;
// *pB = *pA;
break;
default:
assert (false);
break;
}
}
示例4: solveVelocityConstraints
import org.jbox2d.common.Vec2; //導入方法依賴的package包/類
@Override
public void solveVelocityConstraints(final SolverData data) {
Vec2 vB = data.velocities[m_indexB].v;
float wB = data.velocities[m_indexB].w;
// Cdot = v + cross(w, r)
final Vec2 Cdot = pool.popVec2();
Vec2.crossToOutUnsafe(wB, m_rB, Cdot);
Cdot.addLocal(vB);
final Vec2 impulse = pool.popVec2();
final Vec2 temp = pool.popVec2();
temp.set(m_impulse).mulLocal(m_gamma).addLocal(m_C).addLocal(Cdot).negateLocal();
Mat22.mulToOutUnsafe(m_mass, temp, impulse);
Vec2 oldImpulse = temp;
oldImpulse.set(m_impulse);
m_impulse.addLocal(impulse);
float maxImpulse = data.step.dt * m_maxForce;
if (m_impulse.lengthSquared() > maxImpulse * maxImpulse) {
m_impulse.mulLocal(maxImpulse / m_impulse.length());
}
impulse.set(m_impulse).subLocal(oldImpulse);
vB.x += m_invMassB * impulse.x;
vB.y += m_invMassB * impulse.y;
wB += m_invIB * Vec2.cross(m_rB, impulse);
// data.velocities[m_indexB].v.set(vB);
data.velocities[m_indexB].w = wB;
pool.pushVec2(3);
}
示例5: getBox2screen
import org.jbox2d.common.Vec2; //導入方法依賴的package包/類
public Vec2 getBox2screen(float in_box_x, float in_box_y, Vec2 out_screen){
xy1[0] = in_box_x;
xy1[1] = in_box_y;
mat_box2screen.mult(xy1, xy2);
if(out_screen == null){
return new Vec2(xy2[0], xy2[1]);
}
return out_screen.set(xy2[0], xy2[1]);
}
示例6: getScreen2box
import org.jbox2d.common.Vec2; //導入方法依賴的package包/類
public Vec2 getScreen2box(float in_screen_x, float in_screen_y, Vec2 out_box){
xy1[0] = in_screen_x;
xy1[1] = in_screen_y;
mat_screen2box.mult(xy1, xy2);
if(out_box == null){
return new Vec2(xy2[0], xy2[1]);
}
return out_box.set(xy2[0], xy2[1]);
}
示例7: reportParticle
import org.jbox2d.common.Vec2; //導入方法依賴的package包/類
@Override
public boolean reportParticle(int index) {
Vec2 particle_pos = world.getParticlePositionBuffer()[index];
if (query_shape.testPoint(xf, particle_pos)) {
Vec2 particle_vel = world.getParticleVelocityBuffer()[index];
particle_vel.set(vel);
}
return true;
}
示例8: getAnchorA
import org.jbox2d.common.Vec2; //導入方法依賴的package包/類
@Override
public void getAnchorA(Vec2 out) {
out.set(m_bodyA.getPosition());
}
示例9: getAnchorB
import org.jbox2d.common.Vec2; //導入方法依賴的package包/類
@Override
public void getAnchorB(Vec2 out) {
out.set(m_bodyB.getPosition());
}
示例10: getLinearOffset
import org.jbox2d.common.Vec2; //導入方法依賴的package包/類
/**
* Get the target linear offset, in frame A, in meters.
*/
public void getLinearOffset(Vec2 out) {
out.set(m_linearOffset);
}
示例11: getReactionForce
import org.jbox2d.common.Vec2; //導入方法依賴的package包/類
@Override
public void getReactionForce(float inv_dt, Vec2 argOut) {
argOut.set(m_impulse.x, m_impulse.y);
argOut.mulLocal(inv_dt);
}
示例12: getAnchorA
import org.jbox2d.common.Vec2; //導入方法依賴的package包/類
@Override
public void getAnchorA(Vec2 argOut) {
argOut.set(m_targetA);
}
示例13: setMassData
import org.jbox2d.common.Vec2; //導入方法依賴的package包/類
/**
* Set the mass properties to override the mass properties of the fixtures. Note that this changes
* the center of mass position. Note that creating or destroying fixtures can also alter the mass.
* This function has no effect if the body isn't dynamic.
*
* @param massData the mass properties.
*/
public final void setMassData(MassData massData) {
// TODO_ERIN adjust linear velocity and torque to account for movement of center.
assert (m_world.isLocked() == false);
if (m_world.isLocked() == true) {
return;
}
if (m_type != BodyType.DYNAMIC) {
return;
}
m_invMass = 0.0f;
m_I = 0.0f;
m_invI = 0.0f;
m_mass = massData.mass;
if (m_mass <= 0.0f) {
m_mass = 1f;
}
m_invMass = 1.0f / m_mass;
if (massData.I > 0.0f && (m_flags & e_fixedRotationFlag) == 0) {
m_I = massData.I - m_mass * Vec2.dot(massData.center, massData.center);
assert (m_I > 0.0f);
m_invI = 1.0f / m_I;
}
final Vec2 oldCenter = m_world.getPool().popVec2();
// Move center of mass.
oldCenter.set(m_sweep.c);
m_sweep.localCenter.set(massData.center);
// m_sweep.c0 = m_sweep.c = Mul(m_xf, m_sweep.localCenter);
Transform.mulToOutUnsafe(m_xf, m_sweep.localCenter, m_sweep.c0);
m_sweep.c.set(m_sweep.c0);
// Update center of mass velocity.
// m_linearVelocity += Cross(m_angularVelocity, m_sweep.c - oldCenter);
final Vec2 temp = m_world.getPool().popVec2();
temp.set(m_sweep.c).subLocal(oldCenter);
Vec2.crossToOut(m_angularVelocity, temp, temp);
m_linearVelocity.addLocal(temp);
m_world.getPool().pushVec2(2);
}
示例14: getWorldToScreenToOut
import org.jbox2d.common.Vec2; //導入方法依賴的package包/類
/**
* Takes the world coordinates and puts the corresponding screen coordinates in argScreen.
*
* @param worldX
* @param worldY
* @param argScreen
*/
public void getWorldToScreenToOut(float worldX, float worldY, Vec2 argScreen) {
argScreen.set(worldX, worldY);
viewportTransform.getWorldToScreen(argScreen, argScreen);
}
示例15: getScreenToWorldToOut
import org.jbox2d.common.Vec2; //導入方法依賴的package包/類
/**
* takes the screen coordinates and puts the corresponding world coordinates in argWorld.
*
* @param screenX
* @param screenY
* @param argWorld
*/
public void getScreenToWorldToOut(float screenX, float screenY, Vec2 argWorld) {
argWorld.set(screenX, screenY);
viewportTransform.getScreenToWorld(argWorld, argWorld);
}