Package org.earth3d.jearth.math

Examples of org.earth3d.jearth.math.Point3D


    assertEquals(1.0, sphere.getSin(0.25), 0.001);
    assertEquals(-1.0, sphere.getSin(0.75), 0.001);
  }
 
  public void testGetPoint() {
    Point3D result = sphere.getPoint(new Point2D(0,0));
    Point3D result2 = sphere.getPoint(new Point2D(0,0.5));
    Point3D result3 = sphere.getPoint(new Point2D(0,1));
    assertTrue(new Point3D(0,1,0).equals(result));
  }
View Full Code Here


  public HeightfieldTreeNodeCore(Geometry2D3D geo, double radius, HeightfieldTree htree) {
    super(null);

    this.htree = htree;
   
    vertex[0] = new Point3D(0, 0, 0);
    vertex[1] = new Point3D(1, 0, 0);
    vertex[2] = new Point3D(1, 1, 0);
    vertex[3] = new Point3D(0, 1, 0);

    vertexcount = 0;
    vertexarray = null;
    texcoordarray = null;
    dirty = true;
View Full Code Here

        fanvertexarray[direction] = new Point3D[arraysize];

        fantexcoordarray[direction] = new Point2D[arraysize];

        /* fill in the values */
        Point3D nextvertex[] = fanvertexarray[direction];
        int nextvertex_i = 0;
        Point2D nexttexcoord[] = fantexcoordarray[direction];
        int nexttexcoord_i = 0;
        int x = 0, y = 0, r = 0, nextx = 0, nexty = 0;

View Full Code Here

  protected Geometry2D3DSphere gSphere = new Geometry2D3DSphere();
  protected boolean userMouseMoved = false;
 
  public Navigator() {
    speed = 0;
    up = new Point3D(0,1,0);
    autoNavigation = false;
  }
View Full Code Here

    stopAutoNavigation();

    /* rotate the direction vector around the up vector */
    float matrix[] = new float[16];
    Quaternion quat = new Quaternion();
    Point3D viewnorm = viewer.normalize();

    quat.createFromAxisAngle((float) viewnorm.x, (float) viewnorm.y, (float) viewnorm.z, angle);
    quat.createMatrix(matrix);
    Matrix mMatrix = new Matrix(matrix);
   
View Full Code Here

  void elevate(float angle) {
    stopAutoNavigation();

    /* rotate the direction vector around the upXdirection vector */
   
    Point3D upxdir = up.DotP3D(direction);
    upxdir = upxdir.normalize();

    float matrix[] = new float[16];
    Quaternion quat = new Quaternion();
    quat.createFromAxisAngle((float) upxdir.x, (float) upxdir.y, (float) upxdir.z, angle);
    quat.createMatrix(matrix);
View Full Code Here

      autoNavPos += autoNavStep*((float)(timestep)/(1000./50.));
      if (autoNavPos>1) autoNavPos=1;

      autoNavTimeLastFrame = currentTime;

      Point3D newMark2D = sourceMark.multiply(1.-autoNavPos).add(targetMark.multiply(autoNavPos));
      double height = newMark2D.z;
     
      if (isParableFlight()) {
        height += autoNavDistance*(-Math.pow(Math.abs(0.5-autoNavPos),2)+0.25)*10;
        Point3D newMark3D = gSphere.getPoint(new Point2D(newMark2D.x, newMark2D.y), height);
        setViewer(newMark3D);
        setDirection((sourceDir.multiply(1.-autoNavPos).add(targetDir.multiply(autoNavPos).minus(getViewer())).normalize()));
      } else {
        setViewer(newMark2D);
        setDirection((sourceDir.multiply(1.-autoNavPos).add(targetDir.multiply(autoNavPos)).normalize()));
View Full Code Here

  void strafe(float factor) {
    /* rotate the direction by 90 degrees */
    float matrix[] = new float[16];
    Quaternion quat = new Quaternion();
    Point3D norm = viewer.normalize();

    quat.createFromAxisAngle((float) norm.x, (float) norm.y, (float) norm.z, 90);
    quat.createMatrix(matrix);
   
    Matrix mMatrix = new Matrix(matrix);
    Point3D strafedirection = mMatrix.multvector(direction);

    viewer = viewer.add(strafedirection.multiply(factor).multiply(viewer.length()-1));
  }
View Full Code Here

  }

  void forwardOnSurface(float factor) {
    double viewerdistance = viewer.length();

    Point3D v1 = viewer;
    forward(factor);

    // keep distance
    Point3D v2 = viewer;
    viewer = viewer.normalize().multiply(viewerdistance);

    // rotate forward and up
//     double alpha = acos((v2-v1).length()/(viewer-v1).length());
    Point3D v1n = v1.normalize();
    double alpha = Math.acos(viewer.normalize().skalarproduct(v1n));

    Point3D r = (v2.minus(v1)).crossproduct(v2);

    float matrix[] = new float[16];
    Quaternion quat = new Quaternion();
    Point3D norm = r.normalize();

    quat.createFromAxisAngle((float) norm.x, (float) norm.y, (float) norm.z, (float) alpha);
    quat.createMatrix(matrix);
   
    Matrix mMatrix = new Matrix(matrix);
View Full Code Here

  }

  void strafeOnSurface(float factor) {
    double viewerdistance = viewer.length();

    Point3D v1 = viewer;
    strafe(factor);

    // keep distance
    Point3D v2 = viewer;
    viewer = viewer.normalize().multiply(viewerdistance);

    // rotate forward and up
    Point3D v1n = v1.normalize();
    double alpha = Math.acos(viewer.normalize().skalarproduct(v1n));
    Point3D r = (v2.minus(v1)).crossproduct(v2);

    float matrix[] = new float[16];
    Quaternion quat = new Quaternion();
    Point3D norm = r.normalize();

    quat.createFromAxisAngle((float) norm.x, (float) norm.y, (float) norm.z, (float) alpha);
    quat.createMatrix(matrix);

    Matrix mMatrix = new Matrix(matrix);
View Full Code Here

TOP

Related Classes of org.earth3d.jearth.math.Point3D

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.