/** * * @author Chris Thiel, ofmCap * @version Nov 24, 2024 * * Using the notation & formulas of A.R. Forsyth's * Geometry of Four Dimensions * Cambridge University Press, 1930 * https://archive.org/details/geometryoffourdi032760mbp/ * */ public class Point { private double x, y, z, v; public static double rt2ovr2 = Math.sqrt(2)/2.0; public Point() { this(0,0,0,0); } public Point(double x, double y, double z, double v) { this.x=x; this.y=y; this.z=z; this.v=v; } /** * A rotation round the plane YOZ through a1(a') * and round the plane XOV through a2 (a) * @param angles in radian */ public void rotate1(double a1, double a2) { x = x * Math.cos(a1) + v * Math.sin(a1); y = y * Math.cos(a2) + z * Math.sin(a2); z = -y * Math.sin(a2) + z * Math.cos(a2); v = -x * Math.sin(a1) + v * Math.cos(a1); } public int getOrthoX(int x0, int y0, int size) { double x1 = (size * (x + z * rt2ovr2 - v * rt2ovr2)) ; return x0 - (int)x1; } public int getOrthoY(int x0, int y0, int size) { double y1 = (size * (y + z * rt2ovr2 + v * rt2ovr2)) ; return y0 + (int)y1; } public String toString() { return "(" + x + "," + y + "," + z + "," + v + ")"; } }