d2d180935427f137474cd8f12959cb1829566d41
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / renderer / octree / raytracer / Ray.java
1 /*
2  * Sixth 3D engine. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of version 3 of the GNU Lesser General Public License
6  * or later as published by the Free Software Foundation.
7  *
8  */
9
10 package eu.svjatoslav.sixth.e3d.renderer.octree.raytracer;
11
12 public class Ray {
13
14     public double x, y, z;
15
16     public double xp, yp, zp;
17
18     public double hitX, hitY, hitZ;
19
20     public int hitCellSize;
21
22     public int hitCellX, hitCellY, hitCellZ;
23
24     /*
25      * public int orientation;
26      *
27      * public static final int ORIENTATION_RIGHT = 0;
28      *
29      * public static final int ORIENTATION_LEFT = 1;
30      *
31      * public static final int ORIENTATION_DOWN = 2;
32      *
33      * public static final int ORIENTATION_UP = 3;
34      *
35      * public static final int ORIENTATION_FORWARD = 4;
36      *
37      * public static final int ORIENTATION_BACK = 5;
38      *
39      * public static final String orientations[] = { "RIGHT", "LEFT", "DOWN",
40      * "UP", "FORWARD", "BACK" };
41      */
42
43     public Ray(final double X, final double Y, final double Z, final double Xp,
44                final double Yp, final double Zp) {
45         x = X;
46         y = Y;
47         z = Z;
48         xp = Xp;
49         yp = Yp;
50         zp = Zp;
51         // calculateOrientation();
52     }
53
54     /*
55      * public void calculateOrientation() { float axp = Math.abs(xp); float ayp
56      * = Math.abs(yp); float azp = Math.abs(zp);
57      *
58      * if (axp > ayp) { if (axp > azp) { if (xp > 0) { orientation =
59      * ORIENTATION_RIGHT; } else { orientation = ORIENTATION_LEFT; } } else { if
60      * (zp > 0) { orientation = ORIENTATION_FORWARD; } else { orientation =
61      * ORIENTATION_BACK; } } } else { if (ayp > azp) { if (yp > 0) { orientation
62      * = ORIENTATION_DOWN; } else { orientation = ORIENTATION_UP; } } else { if
63      * (zp > 0) { orientation = ORIENTATION_FORWARD; } else { orientation =
64      * ORIENTATION_BACK; } } }
65      *
66      *
67      * }
68      */
69     @Override
70     public String toString() {
71         return "Ray \n" + "     x " + x + "\n" + "      y " + y + "\n" + "      z " + z
72                 + "\n" + "      xp " + xp + "\n" + "    yp " + yp + "\n" + "    zp " + zp
73                 + "\n"; /*
74          * + "  orientation " + orientations[orientation];
75          */
76     }
77 }