Package net.phys2d.math

Examples of net.phys2d.math.Vector2f.scale()


    }

    final Vector2f direction = new Vector2f(p2);
    direction.sub(p1);
    direction.normalise();
    direction.scale(20);

    final Body bodies[] = new Body[N];
    final Vector2f pos = new Vector2f(p1);
    for (int i = 0; i < N; i++) {
      final Body body = new Body(new Box(15, 4), 5);
View Full Code Here


      Vector2f vec = MathUtil.scale(contacts[i].getNormal(),-1);
      contacts[i].setNormal(vec);
     
      Vector2f pt = MathUtil.sub(contacts[i].getPosition(), circleBody.getPosition());
      pt.normalise();
      pt.scale(((Circle) circleBody.getShape()).getRadius());
      pt.add(circleBody.getPosition());
      contacts[i].setPosition(pt);
    }
   
    return count;
View Full Code Here

    if (centre < linePos) {
      if (!line.blocksInnerEdge()) {
        return 0;
      }
     
      normal.scale(-1);
      for (int i=0;i<4;i++) {
        if (tangent[i] > linePos) {
          if (proj[i] < 0) {
            Vector2f onAxis = new Vector2f();
            Line leftLine = new Line(getPt(pts,i-1),pts[i]);
View Full Code Here

    Vector2f impulse = new Vector2f(n);
    impulse.scale(p);
    if (!body1.isStatic()) {
      Vector2f accum1 = new Vector2f(impulse);
      accum1.scale(body1.getInvMass());
      body1.adjustVelocity(accum1);
      body1.adjustAngularVelocity((body1.getInvI() * MathUtil.cross(R,
          impulse)));
    }
    if (!body2.isStatic()) {
View Full Code Here

      body1.adjustAngularVelocity((body1.getInvI() * MathUtil.cross(R,
          impulse)));
    }
    if (!body2.isStatic()) {
      Vector2f accum2 = new Vector2f(impulse);
      accum2.scale(-body2.getInvMass());
      body2.adjustVelocity(accum2);
      body2.adjustAngularVelocity(-(body2.getInvI() * MathUtil.cross(r2,
          impulse)));
    }
  }
 
View Full Code Here

     * relativeVelocity.add(MathUtil.mul(tr1, dp));
     */
    // relativeVelocity.add(MathUtil.cross(dp,body1.getAngularVelocity()));
    n = new Vector2f(-ndp.y, ndp.x);
    Vector2f v1 = new Vector2f(n);
    v1.scale(-body2.getInvMass() - body1.getInvMass());

    Vector2f v2 = MathUtil.cross(MathUtil.cross(r2, n), r2);
    v2.scale(-body2.getInvI());

    Vector2f v3 = MathUtil.cross(MathUtil.cross(R, n), r1);
View Full Code Here

    n = new Vector2f(-ndp.y, ndp.x);
    Vector2f v1 = new Vector2f(n);
    v1.scale(-body2.getInvMass() - body1.getInvMass());

    Vector2f v2 = MathUtil.cross(MathUtil.cross(r2, n), r2);
    v2.scale(-body2.getInvI());

    Vector2f v3 = MathUtil.cross(MathUtil.cross(R, n), r1);
    v3.scale(-body1.getInvI());

    Vector2f K1 = new Vector2f(v1);
View Full Code Here

    Vector2f v2 = MathUtil.cross(MathUtil.cross(r2, n), r2);
    v2.scale(-body2.getInvI());

    Vector2f v3 = MathUtil.cross(MathUtil.cross(R, n), r1);
    v3.scale(-body1.getInvI());

    Vector2f K1 = new Vector2f(v1);
    K1.add(v2);
    K1.add(v3);
View Full Code Here


      biasImpulse = biasFactor * MathUtil.cross(ndp, VA) * invDT;

    Vector2f impulse = new Vector2f(n);
    impulse.scale(accumulateImpulse+biasImpulse);
    if (!body1.isStatic()) {
      Vector2f accum1 = new Vector2f(impulse);
      accum1.scale(body1.getInvMass());
      body1.adjustVelocity(accum1);
      body1.adjustAngularVelocity((body1.getInvI() * MathUtil.cross(R,
 
View Full Code Here

    Vector2f impulse = new Vector2f(n);
    impulse.scale(accumulateImpulse+biasImpulse);
    if (!body1.isStatic()) {
      Vector2f accum1 = new Vector2f(impulse);
      accum1.scale(body1.getInvMass());
      body1.adjustVelocity(accum1);
      body1.adjustAngularVelocity((body1.getInvI() * MathUtil.cross(R,
          impulse)));
    }
    if (!body2.isStatic()) {
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.