home *** CD-ROM | disk | FTP | other *** search
/ Late Night VRML 2.0 with Java CD-ROM / code.zip / Ch18 / multi / Vec3.java < prev    next >
Encoding:
Java Source  |  1997-02-21  |  675 b   |  34 lines

  1. // A simple 3D vector class
  2.  
  3. // Written by Bernie Roehl, December 1996
  4.  
  5. package multi;
  6.  
  7. import java.io.*;
  8.  
  9. public class Vec3 {
  10.     protected float x = 0, y = 0, z = 0;
  11.  
  12.     public Vec3() { }
  13.  
  14.     public Vec3(float xval, float yval, float zval) {
  15.         x = xval;
  16.         y = yval;
  17.         z = zval;
  18.     }
  19.  
  20.     public float getX() { return x; }
  21.     public float getY() { return y; }
  22.     public float getZ() { return z; }
  23.  
  24.     public void read(DataInputStream in) throws IOException {
  25.         x = in.readFloat();
  26.         y = in.readFloat();
  27.         z = in.readFloat();
  28.     }
  29.  
  30.     public String toString() { return x + " " + y + " " + z; }
  31.  
  32. }
  33.  
  34.