2 * Sixth 3D engine. Author: Svjatoslav Agejenko.
3 * This project is released under Creative Commons Zero (CC0) license.
5 package eu.svjatoslav.sixth.e3d.renderer.octree.raytracer;
11 public double xp, yp, zp;
13 public double hitX, hitY, hitZ;
15 public int hitCellSize;
17 public int hitCellX, hitCellY, hitCellZ;
20 * public int orientation;
22 * public static final int ORIENTATION_RIGHT = 0;
24 * public static final int ORIENTATION_LEFT = 1;
26 * public static final int ORIENTATION_DOWN = 2;
28 * public static final int ORIENTATION_UP = 3;
30 * public static final int ORIENTATION_FORWARD = 4;
32 * public static final int ORIENTATION_BACK = 5;
34 * public static final String orientations[] = { "RIGHT", "LEFT", "DOWN",
35 * "UP", "FORWARD", "BACK" };
38 public Ray(final double X, final double Y, final double Z, final double Xp,
39 final double Yp, final double Zp) {
46 // calculateOrientation();
50 * public void calculateOrientation() { float axp = Math.abs(xp); float ayp
51 * = Math.abs(yp); float azp = Math.abs(zp);
53 * if (axp > ayp) { if (axp > azp) { if (xp > 0) { orientation =
54 * ORIENTATION_RIGHT; } else { orientation = ORIENTATION_LEFT; } } else { if
55 * (zp > 0) { orientation = ORIENTATION_FORWARD; } else { orientation =
56 * ORIENTATION_BACK; } } } else { if (ayp > azp) { if (yp > 0) { orientation
57 * = ORIENTATION_DOWN; } else { orientation = ORIENTATION_UP; } } else { if
58 * (zp > 0) { orientation = ORIENTATION_FORWARD; } else { orientation =
59 * ORIENTATION_BACK; } } }
65 public String toString() {
66 return "Ray \n" + " x " + x + "\n" + " y " + y + "\n" + " z " + z
67 + "\n" + " xp " + xp + "\n" + " yp " + yp + "\n" + " zp " + zp
69 * + " orientation " + orientations[orientation];