コード例 #1
0
 void update() {
   Transformation transformation = rigidBody.getTransformation();
   topGroup.setTransformation(transformation);
   double s = 1.5 * shaft.getSizeZ();
   double[] vec = topGroup.toSpaceFrame(new double[] {0, 0, 1});
   orientation.setSizeXYZ(s * vec[0], s * vec[1], s * vec[2]);
   orientationTrace.addPoint(s * vec[0], s * vec[1], s * vec[2]);
   frame.render();
 }
コード例 #2
0
ファイル: CameraApp.java プロジェクト: M0nd4/guide
 public CameraApp() {
   ball.setXYZ(0.0, 0.0, 0.0);
   ball.setSizeXYZ(0.5, 0.5, 0.5);
   ball.getStyle().setFillColor(Color.YELLOW);
   // right wall
   wallR.setXYZ(6.0, 0.0, 0.0);
   wallR.setSizeXYZ(0.2, 4.0, 4.0);
   wallR.getStyle().setFillColor(Color.GREEN);
   // left wall
   wallL.setXYZ(-6.0, 0.0, 0.0);
   wallL.setSizeXYZ(0.2, 4.0, 4.0);
   wallL.getStyle().setFillColor(Color.GREEN);
   // Add the objects
   panel.setPreferredMinMax(-6, 6, -6, 6, -6, 6);
   panel.getInteractionTarget(org.opensourcephysics.display3d.core.DrawingPanel3D.TARGET_PANEL);
   panel.addInteractionListener(this);
   panel.addElement(ball);
   panel.addElement(wallR);
   panel.addElement(wallL);
   DrawingFrame3D frame = new DrawingFrame3D();
   frame.setDrawingPanel3D(panel);
 }
コード例 #3
0
 public SpinningTopSpaceView(SpinningTop rigidBody) {
   this.rigidBody = rigidBody;
   frame.setSize(600, 600);
   // panel.setDisplayMode(VisualizationHints.DISPLAY_NO_PERSPECTIVE);
   double d = 4;
   frame.setPreferredMinMax(-d, d, -d, d, -d, d);
   frame.setDecorationType(
       org.opensourcephysics.display3d.core.VisualizationHints.DECORATION_AXES);
   orientation.getStyle().setFillColor(java.awt.Color.RED);
   orientationTrace.getStyle().setLineColor(java.awt.Color.BLACK);
   base.setSizeXYZ(2, 2, 0.15);
   base.getStyle().setResolution(new Resolution(4, 12, 1));
   base.getStyle().setFillColor(java.awt.Color.RED);
   base.setZ(-3);
   post.setSizeXYZ(0.2, 0.2, 3);
   post.getStyle().setResolution(new Resolution(2, 10, 15));
   post.setZ(-1.5); // shift by half the length
   post.getStyle().setFillColor(java.awt.Color.RED);
   shaft.setSizeXYZ(0.2, 0.2, 3);
   shaft.setXYZ(0, 0, 1.5);
   shaft.getStyle().setResolution(new Resolution(1, 10, 15));
   disk.setSizeXYZ(1.75, 1.75, 0.25);
   disk.setXYZ(0, 0, 2.0);
   disk.getStyle().setResolution(new Resolution(4, 12, 1));
   topGroup.addElement(shaft);
   topGroup.addElement(disk);
   topGroup.setTransformation(rigidBody.getTransformation());
   frame.addElement(base);
   frame.addElement(post);
   frame.addElement(orientation);
   frame.addElement(orientationTrace);
   frame.addElement(topGroup);
 }