Physical Simulation Language: PSL John Hamer hamer John Rodriguez jr534 Danian Martinez djm188 Taino Ortiz tjo22 Background Info • PSL is a language intended for the convenient analysis of motion and.

Download Report

Transcript Physical Simulation Language: PSL John Hamer hamer John Rodriguez jr534 Danian Martinez djm188 Taino Ortiz tjo22 Background Info • PSL is a language intended for the convenient analysis of motion and.

Physical Simulation Language:
PSL
John Hamer
hamer
John Rodriguez
jr534
Danian Martinez
djm188
Taino Ortiz
tjo22
Background Info
• PSL is a language intended for the
convenient analysis of motion and objects
in a 2D 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 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 what he programmed in PSL
– Collision Detection and Reaction
• Attempts to simulate how real world objects handle
collisions in the environment
• Slightly costly
– O(n2) algorithm
PSL Data Flow
This diagram shows the process a .PSL file is put through to become
an executable
Compiler
• ANTLR v2.7.2 was used to develop
PslParser and PslLexer 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, 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 x1, double y1, double x2, double y2)
– Line
• Line(double x1, double y1, double x2, double y2)
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 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 – OpenGL!
• 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
environment using C++/OpenGL
– PslEnvironment = the rendering environment
– PslPolygon, PslSquare, etc…
• For windowing, the GLUT toolkit was used
on Windows XP, Mesa on Redhat Linux.
– Set using PSL Global setter methods
Design of Backend
PslObject
PslTimer
PslShape
PslPoint
PslEnvironment
PslPolygon
PslRectangle
PslSquare
PslCircle
Simple.psl
def circle1 Circle(3, 3, 3);//Creates a circle
circle1.color(255, 0, 0);//Sets color to red
circle1.points(20);
def poly1 Polygon(-5, -5, 3, -5);//Creats a square
Poly1.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.windowSize(300, 300);
Simple.psx
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 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
– Commitment