Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void calculateNormals() {
- normals = new Vector[countSides()];
- Vector u;
- Vector v;
- for(int i = 0; i < normals.length; i++) {
- //U = y - x
- u = vertices[i + 1].substract(vertices[i]);
- //V = z - x;
- v = vertices[i + 2].substract(vertices[i]);
- /*
- Nx = Uy*Vz - Uz*Vy
- Ny = Uz*Vx - Ux*Vz
- Nz = Ux*Vy - Uy*Vx
- */
- normals[i] = new Vector(u.y * v.z - u.z * v.y, u.z * v.x - u.x * v.z, u.x * v.y - u.y * v.x);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment