2 * Sixth 3D engine. Author: Svjatoslav Agejenko.
3 * This project is released under Creative Commons Zero (CC0) license.
8 package eu.svjatoslav.sixth.e3d.renderer.octree.raytracer;
12 public double x, y, z;
14 public double xp, yp, zp;
16 public double hitX, hitY, hitZ;
18 public int hitCellSize;
20 public int hitCellX, hitCellY, hitCellZ;
23 * public int orientation;
25 * public static final int ORIENTATION_RIGHT = 0;
27 * public static final int ORIENTATION_LEFT = 1;
29 * public static final int ORIENTATION_DOWN = 2;
31 * public static final int ORIENTATION_UP = 3;
33 * public static final int ORIENTATION_FORWARD = 4;
35 * public static final int ORIENTATION_BACK = 5;
37 * public static final String orientations[] = { "RIGHT", "LEFT", "DOWN",
38 * "UP", "FORWARD", "BACK" };
41 public Ray(final double X, final double Y, final double Z, final double Xp,
42 final double Yp, final double Zp) {
49 // calculateOrientation();
53 * public void calculateOrientation() { float axp = Math.abs(xp); float ayp
54 * = Math.abs(yp); float azp = Math.abs(zp);
56 * if (axp > ayp) { if (axp > azp) { if (xp > 0) { orientation =
57 * ORIENTATION_RIGHT; } else { orientation = ORIENTATION_LEFT; } } else { if
58 * (zp > 0) { orientation = ORIENTATION_FORWARD; } else { orientation =
59 * ORIENTATION_BACK; } } } else { if (ayp > azp) { if (yp > 0) { orientation
60 * = ORIENTATION_DOWN; } else { orientation = ORIENTATION_UP; } } else { if
61 * (zp > 0) { orientation = ORIENTATION_FORWARD; } else { orientation =
62 * ORIENTATION_BACK; } } }
68 public String toString() {
69 return "Ray \n" + " x " + x + "\n" + " y " + y + "\n" + " z " + z
70 + "\n" + " xp " + xp + "\n" + " yp " + yp + "\n" + " zp " + zp
72 * + " orientation " + orientations[orientation];