Examples of Vec2D


Examples of mods.railcraft.common.util.misc.Vec2D

        Block block = cart.worldObj.getBlock(i, j, k);
        if (isLiving && RailcraftBlocks.getBlockElevator() != null && block == RailcraftBlocks.getBlockElevator())
            return;

//        System.out.println(cart.getClass().getSimpleName() + ": " + cart.entityId + " collided with " + other.getClass().getSimpleName() + ": " + other.entityId);
        Vec2D cartPos = new Vec2D(cart.posX, cart.posZ);
        Vec2D otherPos = new Vec2D(other.posX, other.posZ);

        Vec2D unit = Vec2D.subtract(otherPos, cartPos);
        unit.normalize();

        double distance = cart.getDistanceToEntity(other);
        double depth = distance - OPTIMAL_DISTANCE;

        double forceX = 0;
        double forceZ = 0;

        if (depth < 0) {
            double spring = isPlayer ? COEF_SPRING_PLAYER : COEF_SPRING;
            double penaltyX = spring * depth * unit.getX();
            double penaltyZ = spring * depth * unit.getY();

            forceX += penaltyX;
            forceZ += penaltyZ;

            if (!isPlayer) {
                double impulseX = unit.getX();
                double impulseZ = unit.getY();
                impulseX *= -(1.0 + COEF_RESTITUTION);
                impulseZ *= -(1.0 + COEF_RESTITUTION);

                Vec2D cartVel = new Vec2D(cart.motionX, cart.motionZ);
                Vec2D otherVel = new Vec2D(other.motionX, other.motionZ);

                double dot = Vec2D.subtract(otherVel, cartVel).dotProduct(unit);

                impulseX *= dot;
                impulseZ *= dot;
                impulseX *= 0.5;
                impulseZ *= 0.5;

                forceX -= impulseX;
                forceZ -= impulseZ;
            }
        }

        if (other instanceof EntityMinecart) {
            EntityMinecart otherCart = (EntityMinecart) other;
            if (!cart.isPoweredCart() || otherCart.isPoweredCart())
                if (!RailTools.isCartLockedDown(cart))
                    cart.addVelocity(forceX, 0, forceZ);
            if (!otherCart.isPoweredCart() || cart.isPoweredCart())
                if (!RailTools.isCartLockedDown(otherCart))
                    other.addVelocity(-forceX, 0, -forceZ);
        } else {
//            if(isPlayer) {
//                forceX += Math.abs(cart.motionX - other.motionX) / 2;
//                forceZ += Math.abs(cart.motionZ - other.motionZ) / 2;
//            }
//            System.out.printf("forceX=%f, forceZ=%f%n", forceX, forceZ);
            Vec2D cartVel = new Vec2D(cart.motionX + forceX, cart.motionZ + forceZ);
            Vec2D otherVel = new Vec2D(other.motionX - forceX, other.motionZ - forceZ);

            double dot = Vec2D.subtract(otherVel, cartVel).dotProduct(unit);

            double dampX = COEF_DAMPING * dot * unit.getX();
            double dampZ = COEF_DAMPING * dot * unit.getY();
 
View Full Code Here

Examples of toxi.geom.Vec2D

public class BezierControlNode implements Serializable {
  public Vec2D c1 = new Vec2D(0, 0);
  public Vec2D c2 = new Vec2D(0, 0);

  public BezierControlNode(Vec2D c1In, Vec2D c2In) {
    this.c1 = new Vec2D(c1In.x, c1In.y);
    this.c2 = new Vec2D(c2In.x, c2In.y);

  }
View Full Code Here

Examples of toxi.geom.Vec2D

  }

  @Override
  public BezierControlNode clone() {
    return new BezierControlNode(new Vec2D(this.c1.x, this.c1.y),
        new Vec2D(this.c2.x, this.c2.y));

  }
View Full Code Here

Examples of toxi.geom.Vec2D

    clone.linkedObject = this.linkedObject;
    return clone;
  }

  public void rotate(float r) {
    Vec2D centre = this.outlines.getCentre();
    this.outlines.rotate(r,centre);
    this.collisionOutlines.rotate(r,centre);


  }
View Full Code Here

Examples of toxi.geom.Vec2D

  public Vec2D controlPoint1 = null;
  public Vec2D controlPoint2 = null;

  public spPoint(float x, float y) {
    super(x, y);
    this.controlPoint1 = new Vec2D(x, y);
    this.controlPoint2 = new Vec2D(x, y);
  }
View Full Code Here

Examples of toxi.geom.Vec2D

  public spPoint(Vec2D vec) {
    this.x = vec.x;
    this.y = vec.y;

    this.controlPoint1 = new Vec2D(vec.x, vec.y);
    this.controlPoint2 = new Vec2D(vec.x, vec.y);
  }
View Full Code Here

Examples of toxi.geom.Vec2D

  @Override
  protected spPoint clone() {
    spPoint returnPoint = new spPoint(this.x, this.y);

    if (this.controlPoint1 != null)
      returnPoint.controlPoint1 = new Vec2D(this.controlPoint1.x,
          this.controlPoint1.y);

    if (this.controlPoint2 != null)
      returnPoint.controlPoint2 = new Vec2D(this.controlPoint2.x,
          this.controlPoint2.y);
    return returnPoint;

  }
View Full Code Here

Examples of toxi.geom.Vec2D

      return false;
  }

  public Vec2D getControlPoint1() {
    if (controlPoint1 == null)
      return new Vec2D(this.x, this.y);
    else
      return controlPoint1;
  }
View Full Code Here

Examples of toxi.geom.Vec2D

      return controlPoint1;
  }

  public Vec2D getControlPoint2() {
    if (controlPoint2 == null)
      return new Vec2D(this.x, this.y);
    else
      return controlPoint2;
  }
View Full Code Here

Examples of toxi.geom.Vec2D

      mousePos.x = newX + ((chairCentreOfMass.x) / GLOBAL.jBullet.scale);
      mousePos.y = newY + ((chairCentreOfMass.y) / GLOBAL.jBullet.scale);
      //mousePos.z = centreMouseDeltaZ + chairCentreOfMass.Z;
    }

    Vec2D intersect2D = null;
    if (mousePos != null) {
      intersect2D = new Vec2D(mousePos.x, mousePos.y);
      //intersect2D = new Vec2D(mousePoint.x, mousePoint.y);

    } else {
      intersect2D = new Vec2D(mousePoint.x, mousePoint.y);
    }
    if (intersect2D == null)
      intersect2D = new Vec2D(mousePoint.x, mousePoint.y);

    return intersect2D;

  }
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.