Loading src/main/java/org/example/newmat/GraphicsAndWindowsTest.java +20 −5 Original line number Diff line number Diff line Loading @@ -281,9 +281,24 @@ public class GraphicsAndWindowsTest extends Application { for (MovingObject o : objects) { double x = releaseX - anchorX; double y = releaseY - anchorY; double z = o.getVelocityVec()[2]; // Assume Z is initially unaffected x = min(x, 50); y = min(y, 50); o.setVelocityVec(x,y,o.getVelocityVec()[2]); // Calculate new coordinates based on the rotation of the camera double cosX = Math.cos(Math.toRadians(groupRotX.getAngle())); double sinX = Math.sin(Math.toRadians(groupRotX.getAngle())); double cosY = Math.cos(Math.toRadians(groupRotY.getAngle())); double sinY = Math.sin(Math.toRadians(groupRotY.getAngle())); // Apply transformations double newX = x * cosY + z * sinY; double newZ = z * cosY - x * sinY; double newY = y * cosX + newZ * sinX; newZ = newZ * cosX - y * sinX; // Set the new velocity vector o.setVelocityVec(newX, newY, newZ); } // Remove the sling visualization line Loading src/main/java/org/example/newmat/MillionTriangle.java +20 −6 Original line number Diff line number Diff line Loading @@ -236,12 +236,26 @@ public class MillionTriangle extends Application { //System.out.println("Mouse released at: " + releaseX + ", " + releaseY); for (MovingObject o : objects) { double x = releaseX - anchorX; double y = releaseY - anchorY; double z = o.getVelocityVec()[2]; // Assume Z is initially unaffected x = min(x, 50); y = min(y, 50); o.setVelocityVec(x,y,o.getVelocityVec()[2]); // Calculate new coordinates based on the rotation of the camera double cosX = Math.cos(Math.toRadians(groupRotX.getAngle())); double sinX = Math.sin(Math.toRadians(groupRotX.getAngle())); double cosY = Math.cos(Math.toRadians(groupRotY.getAngle())); double sinY = Math.sin(Math.toRadians(groupRotY.getAngle())); // Apply transformations double newX = x * cosY + z * sinY; double newZ = z * cosY - x * sinY; double newY = y * cosX + newZ * sinX; newZ = newZ * cosX - y * sinX; // Set the new velocity vector o.setVelocityVec(newX, newY, newZ); } // Remove the sling visualization line Loading target/classes/org/example/newmat/GraphicsAndWindowsTest$1.class (5.67 KiB) File changed.No diff preview for this file type. View original file View changed file target/classes/org/example/newmat/GraphicsAndWindowsTest.class +656 B (11.9 KiB) File changed.No diff preview for this file type. View original file View changed file target/classes/org/example/newmat/MillionTriangle$1.class (3.95 KiB) File changed.No diff preview for this file type. View original file View changed file Loading
src/main/java/org/example/newmat/GraphicsAndWindowsTest.java +20 −5 Original line number Diff line number Diff line Loading @@ -281,9 +281,24 @@ public class GraphicsAndWindowsTest extends Application { for (MovingObject o : objects) { double x = releaseX - anchorX; double y = releaseY - anchorY; double z = o.getVelocityVec()[2]; // Assume Z is initially unaffected x = min(x, 50); y = min(y, 50); o.setVelocityVec(x,y,o.getVelocityVec()[2]); // Calculate new coordinates based on the rotation of the camera double cosX = Math.cos(Math.toRadians(groupRotX.getAngle())); double sinX = Math.sin(Math.toRadians(groupRotX.getAngle())); double cosY = Math.cos(Math.toRadians(groupRotY.getAngle())); double sinY = Math.sin(Math.toRadians(groupRotY.getAngle())); // Apply transformations double newX = x * cosY + z * sinY; double newZ = z * cosY - x * sinY; double newY = y * cosX + newZ * sinX; newZ = newZ * cosX - y * sinX; // Set the new velocity vector o.setVelocityVec(newX, newY, newZ); } // Remove the sling visualization line Loading
src/main/java/org/example/newmat/MillionTriangle.java +20 −6 Original line number Diff line number Diff line Loading @@ -236,12 +236,26 @@ public class MillionTriangle extends Application { //System.out.println("Mouse released at: " + releaseX + ", " + releaseY); for (MovingObject o : objects) { double x = releaseX - anchorX; double y = releaseY - anchorY; double z = o.getVelocityVec()[2]; // Assume Z is initially unaffected x = min(x, 50); y = min(y, 50); o.setVelocityVec(x,y,o.getVelocityVec()[2]); // Calculate new coordinates based on the rotation of the camera double cosX = Math.cos(Math.toRadians(groupRotX.getAngle())); double sinX = Math.sin(Math.toRadians(groupRotX.getAngle())); double cosY = Math.cos(Math.toRadians(groupRotY.getAngle())); double sinY = Math.sin(Math.toRadians(groupRotY.getAngle())); // Apply transformations double newX = x * cosY + z * sinY; double newZ = z * cosY - x * sinY; double newY = y * cosX + newZ * sinX; newZ = newZ * cosX - y * sinX; // Set the new velocity vector o.setVelocityVec(newX, newY, newZ); } // Remove the sling visualization line Loading
target/classes/org/example/newmat/GraphicsAndWindowsTest$1.class (5.67 KiB) File changed.No diff preview for this file type. View original file View changed file
target/classes/org/example/newmat/GraphicsAndWindowsTest.class +656 B (11.9 KiB) File changed.No diff preview for this file type. View original file View changed file
target/classes/org/example/newmat/MillionTriangle$1.class (3.95 KiB) File changed.No diff preview for this file type. View original file View changed file