1 / 20

Developing An Educational Rigid Body Dynamics Physics Engine

Developing An Educational Rigid Body Dynamics Physics Engine. By Neal Milstein. Abstract. Goal of Project: To create a rigid-body dynamics physics engine in order to allow physics students to visualize and solve physics models.

mwillett
Download Presentation

Developing An Educational Rigid Body Dynamics Physics Engine

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Developing An Educational Rigid Body Dynamics Physics Engine • By Neal Milstein

  2. Abstract • Goal of Project: To create a rigid-body dynamics physics engine in order to allow physics students to visualize and solve physics models. • Rigid-body dynamics: The study of the motion of non- deformable, free-moving bodies through space.

  3. Abstract (continued) • Engine • Focus on accuracy and speed • Algorithms Used: Runge-Kutta 4, Separate Axis Theorem, collision response via grids of ellipses • Interface • Focus on education, straightforwardness, and free flow

  4. Introduction • Proper visualization of physical models required to properly understand physics concepts. • Computers are used because they replace real-life simulations and have less error margin • My project: simulates rigid bodies and their interactions in two-dimensional space

  5. Micro vs. Macro • Physics engines – Present the unique problem of combining small-scale physical rigid-body oriented interactions with large-scale physics engine design • Micro – Small-scale interactions, algorithms, and designs. e.g. Separate Axis Theorem, Hooke’s Law • Macro – Large-scale design paradigms, architectural patterns. e.g. model-view-controller, separation of interactions from graphics.

  6. Background - Separating Axis Theorem • A line can always be drawn between two concave non-intersecting bodies • What this means: objects are colliding if and only if all separating axes are colliding

  7. Background – Runge-Kutta 4 Integration • Uses weighted average of past slope measurements to estimate h, the best slope estimate for the differential equation at the given time interval. • Much more accurate then Euler’s method, especially over large time step. • Can be used in combination with optimization techniques to calculate differential over many objects.

  8. Development – Model-View-Controller • Separated into Model, View, and Controller (MVC design) • Model - Storage structure for physical components. Includes ways components are grouped and their connections with each other. • View - GUI to which components are displayed. Reads component models and outputs them to screen. Includes User Interface • Controller - Manipulates Models and prepares them for the view. Includes physics engine and physical interactions between models.

  9. Development – First step: Model • Model, underlying structure of physical objects, was developed first. • Made up of classes that store information, with not too many functional methods (by design)

  10. Example of a Model Class package model; publicabstractclass Body extends Element implements Referenceable, Massable, Anchorable, Collideable { protected Reference reference; protecteddoublemass; protectedbooleanisAnchored; privatebooleancolliding = false; public Body(Reference reference, double mass) { this.reference = reference; this.mass = mass; isAnchored = false; } public Body(Reference reference, double mass, boolean isAnchored) { this.reference = reference; this.mass = mass; this.isAnchored = isAnchored; } publicvoid addForce(double forceMag, Vector direction) { double acceleration = forceMag / mass; this.getReference().addAcceleration(new Vector(acceleration, direction)); }

  11. Development – Controller Implementation • Increases time step • Cycles through Interacter objects and calls their interact() method • Passes the model as an argument to the Graphical User Interface • Some current Interacters: • CollisionInteracter (Separating Axis Theorem) • SpringInteracter (Hooke’s Law) • ReferenceableInteracter (Runge-Kutta 4)

  12. Example of an Interacter Class publicclass SpringInteracter extends Interacter { public SpringInteracter(Model model) { super(model); } publicvoid interact() { for (Element e : model) { if (e instanceof Spring) { Spring s = (Spring)e; double forceMag = s.getForce(); Vector direction = s.getBodyA().getReference().getPosition().minus(s.getBodyB().getReference().getPosition()); s.getBodyA().addForce(forceMag, direction); s.getBodyB().addForce(forceMag, direction.getNegative()); } } } }

  13. Collision Response • Generally involve calculations such as rotational momentum, moment of inertia, and conservation of energy • My physics engine uses “grids” of elliptical bodies to simulate the responses to these collisions

  14. Collision Response (Continued) An example of the ellipses grids used to detect collisions. Here, a collision is simulated (programmatically) with the light blue ellipse, which then drags the rest of the shape along with it.

  15. Collision Response (Continued) • Drag forces • Use drag formula to prevent objects from continuously moving • When coupled with a high spring constant, collision response is quite accurate

  16. Development - View • Graphical User Interface • View.render(Model model) method called every time step • View draws the model to the screen • Also contains interface buttons that feed commands back to the controller

  17. Results • Easily create new simulations just by drawing the objects to the GUI or programmatically defining them • Demonstrated Conservation of Energy – Center of Mass always in center of screen.

  18. Functionality • Detect Collisions via the Separate Axis Theorem – collision response (dynamics) on the way • Simulate tension interactions with Hooke’s Law • 2-D motion accurate due to Runge-Kutta 4 • Draw Bodies on screen, have them connected with springs • Simulate any number of bodies in any configuration

  19. Testing Results • Online models of predefined physics problems • Physics textbook problems that can be solved by hand • Testing Conservation of Energy or Momentum

  20. Conclusions • If properly modularized, physics engines can be expandable and scalable. • Key is in separation of programming areas (model from view from controller) • Many physics formulas take new forms in computers.

More Related