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 / Vector2d.class (.txt) < prev    next >
Encoding:
Java Class File  |  2002-06-19  |  1.5 KB  |  72 lines

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