Package peasy.org.apache.commons.math.geometry

Examples of peasy.org.apache.commons.math.geometry.Vector3D


  public PeasyCam(final PApplet parent, PGraphics pg,  final double lookAtX, final double lookAtY,
      final double lookAtZ, final double distance) {
    this.p = parent;
    this.g  = pg;
    this.startCenter = this.center = new Vector3D(lookAtX, lookAtY, lookAtZ);
    this.startDistance = this.distance = distance;
    this.rotation = new Rotation();
    this.originalMatrix = parent.getMatrix((PMatrix3D)null);

    feed();
View Full Code Here


    pan(dragConstraint == Constraint.PITCH ? 0 : -dxMouse * panScale,
        dragConstraint == Constraint.YAW ? 0 : -dyMouse * panScale);
  }

  private void mouseRotate(final double dx, final double dy) {
    final Vector3D u = LOOK.scalarMultiply(100 + .6 * startDistance).negate();

    final int xSign = dx > 0 ? -1 : 1;
    final int ySign = dy < 0 ? -1 : 1;

    final double eccentricity = Math.abs((p.height / 2d) - p.mouseY)
        / (p.height / 2d);
    final double rho = Math.abs((p.width / 2d) - p.mouseX) / (p.width / 2d);

    if (dragConstraint == null || dragConstraint == Constraint.YAW
        || dragConstraint == Constraint.SUPPRESS_ROLL) {
      final double adx = Math.abs(dx) * (1 - eccentricity);
      final Vector3D vx = u.add(new Vector3D(adx, 0, 0));
      rotateY.impulse(Vector3D.angle(u, vx) * xSign);
    }
    if (dragConstraint == null || dragConstraint == Constraint.PITCH
        || dragConstraint == Constraint.SUPPRESS_ROLL) {
      final double ady = Math.abs(dy) * (1 - rho);
      final Vector3D vy = u.add(new Vector3D(0, ady, 0));
      rotateX.impulse(Vector3D.angle(u, vy) * ySign);
    }
    if (dragConstraint == null || dragConstraint == Constraint.ROLL) {
      {
        final double adz = Math.abs(dy) * rho;
        final Vector3D vz = u.add(new Vector3D(0, adz, 0));
        rotateZ.impulse(Vector3D.angle(u, vz) * -ySign
            * (p.mouseX < p.width / 2 ? -1 : 1));
      }
      {
        final double adz = Math.abs(dx) * eccentricity;
        final Vector3D vz = u.add(new Vector3D(0, adz, 0));
        rotateZ.impulse(Vector3D.angle(u, vz) * xSign
            * (p.mouseY > p.height / 2 ? -1 : 1));
      }
    }
  }
View Full Code Here

    return new float[] { (float)center.getX(), (float)center.getY(),
        (float)center.getZ() };
  }

  public void lookAt(final double x, final double y, final double z) {
    centerInterps.startInterpolation(new CenterInterp(new Vector3D(x, y, z), 300));
  }
View Full Code Here

    lookAt(x, y, z, distance, animationTimeMillis);
  }

  public void lookAt(final double x, final double y, final double z,
      final double distance, final long animationTimeMillis) {
    setState(new CameraState(rotation, new Vector3D(x, y, z), distance),
        animationTimeMillis);
  }
View Full Code Here

    this.distance = Math.min(maximumDistance, Math.max(minimumDistance, distance));
    feed();
  }

  public void feed() {
    final Vector3D pos = rotation.applyTo(LOOK).scalarMultiply(distance).add(center);
    final Vector3D rup = rotation.applyTo(UP);
    g.camera((float)pos.getX(), (float)pos.getY(), (float)pos.getZ(), //
        (float)center.getX(), (float)center.getY(), (float)center.getZ(), //
        (float)rup.getX(), (float)rup.getY(), (float)rup.getZ());
  }
View Full Code Here

        (float)rup.getX(), (float)rup.getY(), (float)rup.getZ());
  }

  static void apply(final PGraphics g, final Vector3D center, final Rotation rotation,
      final double distance) {
    final Vector3D pos = rotation.applyTo(LOOK).scalarMultiply(distance).add(center);
    final Vector3D rup = rotation.applyTo(UP);
    g.camera((float)pos.getX(), (float)pos.getY(), (float)pos.getZ(), //
        (float)center.getX(), (float)center.getY(), (float)center.getZ(), //
        (float)rup.getX(), (float)rup.getY(), (float)rup.getZ());
  }
View Full Code Here

   * Where is the PeasyCam in world space?
   *
   * @return float[]{x,y,z}
   */
  public float[] getPosition() {
    final Vector3D pos = rotation.applyTo(LOOK).scalarMultiply(distance).add(center);
    return new float[] { (float)pos.getX(), (float)pos.getY(), (float)pos.getZ() };
  }
View Full Code Here

    setState(new CameraState(new Rotation(), startCenter, startDistance),
        animationTimeInMillis);
  }

  public void pan(final double dx, final double dy) {
    center = center.add(rotation.applyTo(new Vector3D(dx, dy, 0)));
    feed();
  }
View Full Code Here

    return (b * smooth) + (a * (1 - smooth));

  }

  static public Vector3D smooth(final Vector3D a, final Vector3D b, final double t) {
    return new Vector3D(smooth(a.getX(), b.getX(), t), smooth(a.getY(), b.getY(), t),
        smooth(a.getZ(), b.getZ(), t));
  }
View Full Code Here

  static public double linear(final double a, final double b, final double t) {
    return a + (b - a) * t;
  }

  static public Vector3D linear(final Vector3D a, final Vector3D b, final double t) {
    return new Vector3D(linear(a.getX(), b.getX(), t), linear(a.getY(), b.getY(), t),
        linear(a.getZ(), b.getZ(), t));
  }
View Full Code Here

TOP

Related Classes of peasy.org.apache.commons.math.geometry.Vector3D

Copyright © 2018 www.massapicom. 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.