/** Normalize this vector and return the length before normalization. Alters this vector. */ public final float normalize() { float length = length(); if (length < Settings.EPSILON) { return 0f; } float invLength = 1.0f / length; x *= invLength; y *= invLength; return length; }
float maxImpulse = data.step.dt * m_maxForce; if (m_impulse.lengthSquared() > maxImpulse * maxImpulse) { m_impulse.mulLocal(maxImpulse / m_impulse.length());
/** * Initialize the bodies, anchors, lengths, max lengths, and ratio using the world anchors. */ public void initialize(Body b1, Body b2, Vec2 ga1, Vec2 ga2, Vec2 anchor1, Vec2 anchor2, float r) { bodyA = b1; bodyB = b2; groundAnchorA = ga1; groundAnchorB = ga2; localAnchorA = bodyA.getLocalPoint(anchor1); localAnchorB = bodyB.getLocalPoint(anchor2); Vec2 d1 = anchor1.sub(ga1); lengthA = d1.length(); Vec2 d2 = anchor2.sub(ga2); lengthB = d2.length(); ratio = r; assert (ratio > Settings.EPSILON); } }
public float getCurrentLengthA() { final Vec2 p = pool.popVec2(); m_bodyA.getWorldPointToOut(m_localAnchorA, p); p.subLocal(m_groundAnchorA); float length = p.length(); pool.pushVec2(1); return length; }
public float getCurrentLengthB() { final Vec2 p = pool.popVec2(); m_bodyB.getWorldPointToOut(m_localAnchorB, p); p.subLocal(m_groundAnchorB); float length = p.length(); pool.pushVec2(1); return length; }
public float getLength1() { final Vec2 p = pool.popVec2(); m_bodyA.getWorldPointToOut(m_localAnchorA, p); p.subLocal(m_groundAnchorA); float len = p.length(); pool.pushVec2(1); return len; }
public float getLength2() { final Vec2 p = pool.popVec2(); m_bodyB.getWorldPointToOut(m_localAnchorB, p); p.subLocal(m_groundAnchorB); float len = p.length(); pool.pushVec2(1); return len; }
for (int i = 0; i < targetLengths.length; ++i) { final int next = (i == targetLengths.length - 1) ? 0 : i + 1; float dist = bodies[i].getWorldCenter().sub(bodies[next].getWorldCenter()).length(); targetLengths[i] = dist;
/** * Initialize the bodies, anchors, and length using the world anchors. * * @param b1 First body * @param b2 Second body * @param anchor1 World anchor on first body * @param anchor2 World anchor on second body */ public void initialize(final Body b1, final Body b2, final Vec2 anchor1, final Vec2 anchor2) { bodyA = b1; bodyB = b2; localAnchorA.set(bodyA.getLocalPoint(anchor1)); localAnchorB.set(bodyB.getLocalPoint(anchor2)); Vec2 d = anchor2.sub(anchor1); length = d.length(); } }
Body b = fixture.getBody(); liquidOffset.set(b.m_linearVelocity); float linVelLength = b.m_linearVelocity.length(); if (averageLinearVel == -1) { averageLinearVel = linVelLength;
m_length = m_u.length();
float length = m_u.length(); if (length > Settings.linearSlop) { m_u.x *= 1.0f / length;
Rot.mulToOutUnsafe(qB, C.set(m_localAnchorB).subLocal(m_localCenterB), rB); C.set(cB).addLocal(rB).subLocal(cA).subLocal(rA); positionError = C.length();
public float getCurrentLengthB() { final Vec2 p = pool.popVec2(); m_bodyB.getWorldPointToOut(m_localAnchorB, p); p.subLocal(m_groundAnchorB); float length = p.length(); pool.pushVec2(1); return length; }
public float getLength1() { final Vec2 p = pool.popVec2(); m_bodyA.getWorldPointToOut(m_localAnchorA, p); p.subLocal(m_groundAnchorA); float len = p.length(); pool.pushVec2(1); return len; }
public float op(Vec2 argVec) { argVec.set(MathUtils.randomFloat(-100, 100), MathUtils.randomFloat(-100, 100)); argVec.mulLocal(3.2f); float s = argVec.length(); argVec.normalize(); return s; }
public float op(Vec2 argVec) { argVec.set(MathUtils.randomFloat(-100, 100), MathUtils.randomFloat(-100, 100)); argVec.mulLocal(3.2f); float s = argVec.length(); argVec.normalize(); return s; }