Package org.nlogo.api

Examples of org.nlogo.api.Vect


    double zOff = w.minPzcor() + ((w.maxPzcor() - w.minPzcor()) / 2.0);
    ozcor(zOff + (StrictMath.max
        (world.worldWidth(),
         StrictMath.max(world.worldHeight(), w.worldDepth())) * 2));

    rotationPoint = new Vect(oxcor(), oycor(), zOff);
    right = new Vect(1, 0, 0);
    forward = new Vect(0, 0, 1);
  }
View Full Code Here


  @Override
  public void orbitRight(double delta) {
    right = right.correct();
    forward = forward.correct();

    Vect cors = new Vect(oxcor(), oycor(), ozcor());
    Vect up = forward.cross(right);
    Vect xaxis = new Vect(1, 0, 0);
    Vect upxy = new Vect(up.x(), up.y(), 0);
    upxy = upxy.normalize();

    if (up.z() > 0) {
      delta = -delta;
    }

    cors = cors.subtract(rotationPoint);

    cors = cors.rotateZ(delta);
    right = right.rotateZ(delta);
    forward = forward.rotateZ(delta);

    cors = cors.add(rotationPoint);

    Vect rightxy = new Vect(right.x(), right.y(), 0);
    rightxy = rightxy.normalize();
    heading = StrictMath.toDegrees(rightxy.angleTo(xaxis));

    oxyandzcor(cors.x(), cors.y(), cors.z());
  }
View Full Code Here

  private Vect right;

  @Override
  public void orbitUp(double delta) {
    // translate the rotation point to the origin.
    Vect pos = new Vect(oxcor() - rotationPoint.x(),
        oycor() - rotationPoint.y(),
        ozcor() - rotationPoint.z());

    // use the right vector rather than the forward vector
    // to determine the "heading" so it is continuous.
    // might make craig less cranky to make this change
    // everywhere but not today.
    Vect rightxy =
        new Vect(right.x(), right.y(), 0)
            .correct().normalize();
    //measure from the x-axis because that's where
    // the right vector, rests and heading = 0
    Vect xaxis = new Vect(1, 0, 0);

    // convert to degrees since rotateX/Z expect degrees
    double angle = StrictMath.toDegrees(rightxy.angleTo(xaxis));

    // rotate around the z-axis so the rotation
View Full Code Here

  }

  @Override
  public void translate(double thetaX, double thetaY) {
    Vect[] v = Vect.toVectors(heading, pitch, roll);
    Vect ortho = v[1].cross(v[0]);

    oxcor(oxcor() - v[1].x() * thetaX * 0.1);
    oycor(oycor() - v[1].y() * thetaX * 0.1);
    ozcor(ozcor() + v[1].z() * thetaX * 0.1);

    rotationPoint = new Vect
        (rotationPoint.x() - v[1].x() * thetaX * 0.1,
         rotationPoint.y() - v[1].y() * thetaX * 0.1,
         rotationPoint.z() + v[1].z() * thetaX * 0.1);

    oxcor(oxcor() + ortho.x() * thetaY * 0.1);
    oycor(oycor() + ortho.y() * thetaY * 0.1);
    ozcor(ozcor() - ortho.z() * thetaY * 0.1);

    rotationPoint = new Vect
        (rotationPoint.x() + ortho.x() * thetaY * 0.1,
         rotationPoint.y() + ortho.y() * thetaY * 0.1,
         rotationPoint.z() - ortho.z() * thetaY * 0.1);
  }
View Full Code Here

    // handles wrapping its own way
    {
      return false;
    }

    Vect unitVect = Vect.toVectors(h, p, 0)[0];
    Vect targetVect = new Vect(x - cx, y - cy, z - cz);
    double angle = targetVect.angleTo(unitVect);
    double halfRadians = StrictMath.toRadians(half);

    return angle <= halfRadians || angle >= (2 * StrictMath.PI - halfRadians);
  }
View Full Code Here

  public void setRotationPoint(Vect v) {
    rotationPoint = v;
  }

  public void setRotationPoint(double x, double y, double z) {
    rotationPoint = new Vect(x, y, z);
  }
View Full Code Here

    double cosH = StrictMath.cos(headingR);

    _oxcor -= ((cosH * thetaX + sinH * thetaY) * 0.1);
    _oycor += ((sinH * thetaX - cosH * thetaY) * 0.1);

    rotationPoint = new Vect(rotationPoint.x() - ((cosH * thetaX + sinH * thetaY) * 0.1),
        rotationPoint.y() + ((sinH * thetaX - cosH * thetaY) * 0.1),
        rotationPoint.z());
  }
View Full Code Here

    }
    if (StrictMath.abs(cosDelta) < org.nlogo.api.Constants.Infinitesimal()) {
      cosDelta = 0;
    }

    Vect turnForward = new Vect(-sinDelta, cosDelta, 0);

    Vect turnRight = new Vect(cosDelta, sinDelta, 0);

    Vect orthogonal = v[1].cross(v[0]);

    Vect forward =
        Vect.axisTransformation(turnForward, v[1], v[0], orthogonal);
    Vect right =
        Vect.axisTransformation(turnRight, v[1], v[0], orthogonal);

    return Vect.toAngles(forward, right);
  }
View Full Code Here

TOP

Related Classes of org.nlogo.api.Vect

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.