41 lines
767 B
Java
41 lines
767 B
Java
|
package renderSuite;
|
||
|
|
||
|
import java.lang.Math;
|
||
|
|
||
|
public class Vec3 {
|
||
|
public double x, y, z;
|
||
|
|
||
|
public Vec3(double x, double y, double z) {
|
||
|
this.x = x;
|
||
|
this.y = y;
|
||
|
this.z = z;
|
||
|
}
|
||
|
|
||
|
public void main(double x, double y, double z) {
|
||
|
this.x = x;
|
||
|
this.y = y;
|
||
|
this.z = z;
|
||
|
}
|
||
|
|
||
|
public double len() {
|
||
|
return Math.sqrt(this.x*this.x + this.y*this.y + this.z*this.z);
|
||
|
}
|
||
|
|
||
|
public void normalize() {
|
||
|
double l = len();
|
||
|
|
||
|
this.x /= l;
|
||
|
this.y /= l;
|
||
|
this.z /= l;
|
||
|
}
|
||
|
|
||
|
public Vec3 get_norm() {
|
||
|
double l = len();
|
||
|
return new Vec3(this.x / l, this.y / l, this.z / l);
|
||
|
}
|
||
|
|
||
|
public Vec3 copy() {
|
||
|
return new Vec3(this.x, this.y, this.z);
|
||
|
}
|
||
|
}
|