Physical Simulation Language: PSLBackground InfoPurposeKey FeaturesPSL Data FlowCompilerPSL ObjectsAbstract Syntax TreeIntermediate Code GeneratorBackendBackend (continued)Design of BackendSimple.pslSimple.psxTesting PlanConclusionLessonsPhysical Simulation Language:PSLJohn Hamer John Rodriguez Danian Martinez Taino Ortiz hamer jr534 djm188 tjo22Background 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 queueingPurpose•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) algorithmPSL Data FlowThis diagram shows the process a .PSL file is put through to becomean executableCompiler•ANTLR v2.7.2 was used to develop PslParser and PslLexer via our language-specific CFG•We decided to implement our own treewalker, which assisted ANTLR in performing semantic analysis of the resultant ASTsPSL 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 curveBackend (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 methodsDesign of BackendP s l T i m e rP s l P o i n tP s l S q u a r eP s l R e c t a n g l eP s l C i r c l eP s l P o l y g o nP s l S h a p eP s l E n v i r o n m e n tP s l O b j e c tSimple.psldef circle1 Circle(3, 3, 3);//Creates a circlecircle1.color(255, 0, 0);//Sets color to redcircle1.points(20);def poly1 Polygon(-5, -5, 3, -5);//Creats a squarePoly1.addpoint(-2.5, -2.5)poly.color(0, 0, 255);//Sets color to blueGlobal.zoom(15);//Set the camera zoom/* Sets window size */Global.windowSize(300, 300);Simple.psxTesting 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 semanticsConclusion•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
View Full Document