oop-labs-collection/labs/3/renderSuite/Vec3.java

41 lines
767 B
Java
Raw Permalink Normal View History

2023-04-27 14:23:46 +03:00
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);
}
}