21 private float[] values =
new float[3];
23 public VSFVec3f(
float x,
float y,
float z)
32 if (values.length != 3) {
33 this.values[0] = values[0];
34 this.values[1] = values[1];
35 this.values[2] = values[2];
41 public VSFVec3f(DataInputStream in)
throws IOException
43 values[0] = in.readFloat();
44 values[1] = in.readFloat();
45 values[2] = in.readFloat();
48 public void write(DataOutputStream out)
throws IOException
50 out.writeFloat(values[0]);
51 out.writeFloat(values[1]);
52 out.writeFloat(values[2]);
55 public String toString()
57 return "(" + values[0] +
", " + values[1] +
", " + values[2] +
")";
60 public byte getType() {
return SFVEC3F; }
62 public float[] getValue() {
return values; }
65 return new VSFVec3f(values[0] + v.values[0],
66 values[1] + v.values[1],
67 values[2] + v.values[2]);
71 return new VSFVec3f(values[0] - v.values[0],
72 values[1] - v.values[1],
73 values[2] - v.values[2]);
84 public double getDistance(
VSFVec3f v) {
91 x = (double)(values[0] - v.values[0]);
92 y = (double)(values[1] - v.values[1]);
93 z = (double)(values[2] - v.values[2]);
95 distance = Math.sqrt((x*x) + (y*y) + (z*z));
106 delta_x = (double) (values[0] - v.values[0]);
108 delta_z = (double) (v.values[2] - values[2]);
109 angle = Math.atan2(delta_z, delta_x);