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 / Vector3f.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 Vector3f extends Tuple3f implements Serializable {
  6.    static final long serialVersionUID = -7031930069184524614L;
  7.  
  8.    public Vector3f(float var1, float var2, float var3) {
  9.       super(var1, var2, var3);
  10.    }
  11.  
  12.    public Vector3f(float[] var1) {
  13.       super(var1);
  14.    }
  15.  
  16.    public Vector3f(Vector3f var1) {
  17.       super(var1);
  18.    }
  19.  
  20.    public Vector3f(Vector3d var1) {
  21.       super(var1);
  22.    }
  23.  
  24.    public Vector3f(Tuple3f var1) {
  25.       super(var1);
  26.    }
  27.  
  28.    public Vector3f(Tuple3d var1) {
  29.       super(var1);
  30.    }
  31.  
  32.    public Vector3f() {
  33.    }
  34.  
  35.    public final float lengthSquared() {
  36.       return this.x * this.x + this.y * this.y + this.z * this.z;
  37.    }
  38.  
  39.    public final float length() {
  40.       return (float)Math.sqrt((double)(this.x * this.x + this.y * this.y + this.z * this.z));
  41.    }
  42.  
  43.    public final void cross(Vector3f var1, Vector3f var2) {
  44.       float var3 = var1.y * var2.z - var1.z * var2.y;
  45.       float var4 = var2.x * var1.z - var2.z * var1.x;
  46.       this.z = var1.x * var2.y - var1.y * var2.x;
  47.       this.x = var3;
  48.       this.y = var4;
  49.    }
  50.  
  51.    public final float dot(Vector3f var1) {
  52.       return this.x * var1.x + this.y * var1.y + this.z * var1.z;
  53.    }
  54.  
  55.    public final void normalize(Vector3f var1) {
  56.       float var2 = (float)((double)1.0F / Math.sqrt((double)(var1.x * var1.x + var1.y * var1.y + var1.z * var1.z)));
  57.       this.x = var1.x * var2;
  58.       this.y = var1.y * var2;
  59.       this.z = var1.z * var2;
  60.    }
  61.  
  62.    public final void normalize() {
  63.       float var1 = (float)((double)1.0F / Math.sqrt((double)(this.x * this.x + this.y * this.y + this.z * this.z)));
  64.       this.x *= var1;
  65.       this.y *= var1;
  66.       this.z *= var1;
  67.    }
  68.  
  69.    public final float angle(Vector3f var1) {
  70.       double var2 = (double)(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 (float)Math.acos(var2);
  80.    }
  81. }
  82.