Package org.jbox2d.common

Examples of org.jbox2d.common.Vec2.normalize()


            dc.getBody().applyForce(pAToShape,shapePos);
          }
        }else if(Vec2.dot(pBToShape, vecBToA)<0){
          if(pBToShape.lengthSquared()>ASBOTXConfigs.E_SQUARE){
            pBToShape.negateLocal();
            pBToShape.normalize();
            pBToShape.mulLocal(FORCE_MAGNITUDE);
            dc.getBody().applyForce(pBToShape,shapePos);
          }
        }else{
          dc.getBody().applyForce(Vec2.cross(pAToShape,vecAToB)>0?forces[0]:forces[1],shapePos);
View Full Code Here


       
        v=center.sub(dc.getBody().getPosition());
        float lengthS=v.lengthSquared();
       
        if(lengthS>ASBOTXConfigs.E_SQUARE){
          v.normalize();
          v.mulLocal((float)radius*K*dc.getBody().getMass());
          dc.getBody().applyForce(v, dc.getBody().getWorldCenter());
        }
      }
    }
View Full Code Here

          }
        }
        final Vec2 n = tempVec;
        tempVec.x = px + t * vx;
        tempVec.y = py + t * vy;
        n.normalize();
        final Vec2 point = tempVec2;
        point.x = point1.x + t * vx;
        point.y = point1.y + t * vy;
        float f = callback.reportParticle(i, point, n, t);
        fraction = MathUtils.min(fraction, f);
View Full Code Here

    Mat22.mulToOut(b2.getTransform().R, r2, r2);
   
    d.x = b2.m_sweep.c.x + r2.x - b1.m_sweep.c.x - r1.x;
    d.y = b2.m_sweep.c.y + r2.y - b1.m_sweep.c.y - r1.y;
   
    float length = d.normalize();
    float C = length - m_length;
    C = MathUtils.clamp(C, -Settings.maxLinearCorrection, Settings.maxLinearCorrection);
   
    float impulse = -m_mass * C;
    m_u.set(d);
 
View Full Code Here

          }
        }
        final Vec2 n = tempVec;
        tempVec.x = px + t * vx;
        tempVec.y = py + t * vy;
        n.normalize();
        final Vec2 point = tempVec2;
        point.x = point1.x + t * vx;
        point.y = point1.y + t * vy;
        float f = callback.reportParticle(i, point, n, t);
        fraction = MathUtils.min(fraction, f);
View Full Code Here

    final Vec2 v1 = m_vertex1;
    final Vec2 v2 = m_vertex2;
    final Vec2 normal = pool2.set(v2).subLocal(v1);
    normal.set(normal.y, -normal.x);
    normal.normalize();

    // q = p1 + t * d
    // dot(normal, q - v1) = 0
    // dot(normal, p1 - v1) + t * dot(normal, d) = 0
    pool3.set(v1).subLocal(p1);
View Full Code Here

      PrismaticJointDef pjd = new PrismaticJointDef();

      // Bouncy limit
      Vec2 axis = new Vec2(2.0f, 1.0f);
      axis.normalize();
      pjd.initialize(ground, body, new Vec2(0.0f, 0.0f), axis);

      // Non-bouncy limit
      // pjd.Initialize(ground, body, Vec2(-10.0f, 10.0f), Vec2(1.0f, 0.0f));
View Full Code Here

      Vec2 d = center.sub(position);
      if (d.lengthSquared() < Settings.EPSILON * Settings.EPSILON) {
        continue;
      }

      d.normalize();
      Vec2 F = d.mulLocal(100f);
      body.applyForce(F, position);
    }
  }

View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.