Benützer:


Panel General y Elementos

Storyboard

>Modell

ID:(1080, 0)



OSP Moviomeinto de Figuras 3D

Beschreibung

>Top


En el caso de la pelota que rebota se puede emplear el código:

```

/**

* www.opensourcephysics.org/

* @author Wolfgang Christian

*/

import org.opensourcephysics.controls.AbstractSimulation;

import org.opensourcephysics.display3d.simple3d.*;

public class BounceApp extends AbstractSimulation {

DrawingPanel3D panel = new DrawingPanel3D();

DrawingFrame3D frame = new DrawingFrame3D(panel);

Element ball = new ElementEllipsoid();

Element floor = new ElementBox();

double velocity = 0;

public BounceApp() {

panel.setPreferredMinMax(-5, 5, -5, 5, 0, 10);

ball.setXYZ(0.0, 0.0, 9.0);

ball.setSizeXYZ(2, 2, 2);

ball.getStyle().setFillColor(java.awt.Color.YELLOW);

// floor

floor.setXYZ(0.0, 0.0, 0.0);

floor.setSizeXYZ(5.0, 5.0, 1.0);

// Add the objects to panel

panel.addElement(ball);

panel.addElement(floor);

frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);

frame.setVisible(true);

}

protected void doStep() {

double z = ball.getZ(), dt = 0.05;

z += velocity*dt; // moves the ball

velocity -= 9.8*dt; // acceleration changes the velocity

if(z<=1.0&&velocity<0) {

velocity = -velocity;

}

ball.setZ(z);

}

public static void main(String[] args) {

(new BounceApp()).startSimulation();

}

}

```

ID:(8764, 0)



Elemente hinzufügen - Ein Fläche

Beschreibung

>Top


ID:(1229, 0)



Animation

Beschreibung

>Top


ID:(1230, 0)