Physical Simulation Language PSL John Hamer hamer John

  • Slides: 17
Download presentation
Physical Simulation Language: PSL John Hamer hamer John Rodriguez jr 534 Danian Martinez djm

Physical Simulation Language: PSL John Hamer hamer John Rodriguez jr 534 Danian Martinez djm 188 Taino Ortiz tjo 22

Background Info • PSL is a language intended for the convenient analysis of motion

Background Info • PSL is a language intended for the convenient analysis of motion and objects in a 2 D space. • Other languages, such as Direct X, make even the simplest simulation a bother. – Window management issues – Efficient memory handling, message queueing

Purpose • PSL was created for two reasons: – To facilitate the creation of

Purpose • PSL was created for two reasons: – To facilitate the creation of simple polygonal shapes using a simple language. – To feature interaction among these objects for the demonstration of physical principles.

Key Features • Key Features of PSL – Graphical Display • Immediate response to

Key Features • Key Features of PSL – Graphical Display • Immediate response to what he programmed in PSL – Collision Detection and Reaction • Attempts to simulate how real world objects handle collisions in the environment • Slightly costly – O(n 2) algorithm

PSL Data Flow This diagram shows the process a. PSL file is put through

PSL Data Flow This diagram shows the process a. PSL file is put through to become an executable

Compiler • ANTLR v 2. 7. 2 was used to develop Psl. Parser and

Compiler • ANTLR v 2. 7. 2 was used to develop Psl. Parser and Psl. Lexer via our languagespecific CFG • We decided to implement our own treewalker, which assisted ANTLR in performing semantic analysis of the resultant ASTs

PSL Objects • Possible objects in PSL – Circle • Circle(double center_x, double center_y,

PSL Objects • Possible objects in PSL – Circle • Circle(double center_x, double center_y, double radius) – Rectangle • Rectangle(double x, double y, double length, double width) – Square • Square(double x, double y, double length) – Polygon – convex AND concave • Poly(double x 1, double y 1, double x 2, double y 2) – Line • Line(double x 1, double y 1, double x 2, double y 2)

Abstract Syntax Tree • Each statement is composed of a subtree known as a

Abstract Syntax Tree • Each statement is composed of a subtree known as a child with the first token as the root and all proceeding tokens its children • Value list become children of the Object that is being created of altered. • The AST that ANTLR generates is read as a list and using the API provided by their AST files they are processed one child at a time.

Intermediate Code Generator • Takes in – One vector of all objects – All

Intermediate Code Generator • Takes in – One vector of all objects – All global variables defined • Abides by PSL-specific C++ template to generate appropriate environment and object specifications • Writes the corresponding C++ source file – PSL “bytecode”

Backend • Graphics programming already has a commonly-used API – Open. GL! • Often

Backend • Graphics programming already has a commonly-used API – Open. GL! • Often complicated and error prone – Complicates the simplest demo – Not for rookies… • PSL implements its powerful capabilities while eliminating the learning curve

Backend (continued) • The backend of the PSL language implemented a carefully structured OO

Backend (continued) • The backend of the PSL language implemented a carefully structured OO environment using C++/Open. GL – Psl. Environment = the rendering environment – Psl. Polygon, Psl. Square, etc… • For windowing, the GLUT toolkit was used on Windows XP, Mesa on Redhat Linux. – Set using PSL Global setter methods

Design of Backend

Design of Backend

Simple. psl def circle 1 Circle(3, 3, 3); //Creates a circle 1. color(255, 0,

Simple. psl def circle 1 Circle(3, 3, 3); //Creates a circle 1. color(255, 0, 0); //Sets color to red circle 1. points(20); def poly 1 Polygon(-5, 3, -5); //Creats a square Poly 1. addpoint(-2. 5, -2. 5) poly. color(0, 0, 255); //Sets color to blue Global. zoom(15); //Set the camera zoom /* Sets window size */ Global. window. Size(300, 300);

Simple. psx

Simple. psx

Testing Plan • Modular Testing – Tested each module before integrating • Regression Testing

Testing Plan • Modular Testing – Tested each module before integrating • Regression Testing – Tested new modules to verify that they worked with the other modules • Integration Testing – Integration of front and Backend • This Test verified that the language worked • Error Testing – Used to verify that the compiler threw errors for incorrect syntax and/or semantics

Conclusion • PSL is a valuable asset – To the graphics designer, executive, or

Conclusion • PSL is a valuable asset – To the graphics designer, executive, or engineer who must incorporate graphical displays into their everyday assignments. – A lecture given by a high school physics professor will be much more effective with PSL -designed presentations in his or her arsenal.

Lessons • Three very important properties of a good team – Trust – Communication

Lessons • Three very important properties of a good team – Trust – Communication – Commitment