home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &… the Search for Life CD 3 / 0_CD-ROM.iso / install / jre1_3 / lib / ext / vecmath.jar / javax / vecmath / Vector3d.class (.txt) < prev    next >
Encoding:
Java Class File  |  2002-06-19  |  1.9 KB  |  82 lines

  1. package javax.vecmath;
  2.  
  3. import java.io.Serializable;
  4.  
  5. public class Vector3d extends Tuple3d implements Serializable {
  6.    static final long serialVersionUID = 3761969948420550442L;
  7.  
  8.    public Vector3d(double var1, double var3, double var5) {
  9.       super(var1, var3, var5);
  10.    }
  11.  
  12.    public Vector3d(double[] var1) {
  13.       super(var1);
  14.    }
  15.  
  16.    public Vector3d(Vector3d var1) {
  17.       super(var1);
  18.    }
  19.  
  20.    public Vector3d(Vector3f var1) {
  21.       super(var1);
  22.    }
  23.  
  24.    public Vector3d(Tuple3f var1) {
  25.       super(var1);
  26.    }
  27.  
  28.    public Vector3d(Tuple3d var1) {
  29.       super(var1);
  30.    }
  31.  
  32.    public Vector3d() {
  33.    }
  34.  
  35.    public final void cross(Vector3d var1, Vector3d var2) {
  36.       double var3 = var1.y * var2.z - var1.z * var2.y;
  37.       double var5 = var2.x * var1.z - var2.z * var1.x;
  38.       this.z = var1.x * var2.y - var1.y * var2.x;
  39.       this.x = var3;
  40.       this.y = var5;
  41.    }
  42.  
  43.    public final void normalize(Vector3d var1) {
  44.       double var2 = (double)1.0F / Math.sqrt(var1.x * var1.x + var1.y * var1.y + var1.z * var1.z);
  45.       this.x = var1.x * var2;
  46.       this.y = var1.y * var2;
  47.       this.z = var1.z * var2;
  48.    }
  49.  
  50.    public final void normalize() {
  51.       double var1 = (double)1.0F / Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  52.       this.x *= var1;
  53.       this.y *= var1;
  54.       this.z *= var1;
  55.    }
  56.  
  57.    public final double dot(Vector3d var1) {
  58.       return this.x * var1.x + this.y * var1.y + this.z * var1.z;
  59.    }
  60.  
  61.    public final double lengthSquared() {
  62.       return this.x * this.x + this.y * this.y + this.z * this.z;
  63.    }
  64.  
  65.    public final double length() {
  66.       return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  67.    }
  68.  
  69.    public final double angle(Vector3d var1) {
  70.       double var2 = this.dot(var1) / (this.length() * var1.length());
  71.       if (var2 < (double)-1.0F) {
  72.          var2 = (double)-1.0F;
  73.       }
  74.  
  75.       if (var2 > (double)1.0F) {
  76.          var2 = (double)1.0F;
  77.       }
  78.  
  79.       return Math.acos(var2);
  80.    }
  81. }
  82.