Unformatted text preview:

1 Image removed due to copyright restrictions. Design Project Experiences: Space Elevator Simulator Part II 6.170 Page 1 12 • • . • • • Image removed due to copyright restrictions. “Realistic” Space Elevator Edwards & Westling, 2002 Spacecraft launched into geosynchronous (35,000km) orbit. Spacecraft lowers thin ribbon toward ground, and moves outward to keep it from falling, eventually ending up at 100,000 km to act as a counterweightWhen ribbon reaches earth, it is tied to a base station (floating platform off the coast of Ecuador). To strengthen and widen the initial ribbon, climbers, powered by lasers from earth stitch on additional ribbons for 2½ years. Ribbon is 3 feet wide and supports 13 tons in completed elevator. Page 2 23 “” ’…nd. Space Elevator Quotes The space elevator will be built about 50 years after everyone stops laughing.- Arthur C. Clarke, 1985 "It ll be built 10 years after everybody stops laughing and I think they have stopped laughing," Arthur C. Clarke, 2003, 2 Annual Space Elevator conference, New MexicoPage 3 34 • • j– • • – – →Functionality Simulate and view space elevator dynamics Main ob ects are Central planet, cable, counterweight, climber Cable modeled as masses and springs Main forces are gravitational, centrifugal and coriolis Different views: Text file Swing Java 3D Because of Coriolis force, the object does not actually deviate from its path, but it appears to do so because of the motion of the coordinate system. Page 4 45 ’ j llll j lli lli ld il i iMDD Main World SimStruct TimeSim SimOut Creation, mutation Displays SimOut Startup, refresh Startup, refresh SimOut Viewer Draw (Swing) Dynamically updates and reads SimStruct Constructor Invokes TimeSim methods Calls Draw methods Calls Draw methods Editor Let s have ob ects in the World cal Draw methods and draw themselves. This makes for a more extensible wor d because we can add modu es and add their draw methods. Similar y, we will have ob ects in Wor d call the simulator methods to simu ate their dynamics. In this MDD it is clear that World s the central module/ADT. Wor d and Editor are tightly coupled since the Wor d will need to invoke Editor methods to edit its objects, and the ed tor will need to invoke Wormethods to update the objects w th new ones, or update object positions. Wor d objects call methods in Draw and T meS m to draw or simulate themselves. Page 5 56 • • ’il ll i ji l jlili i li l ldEl i l iClass Hierarchy (partial) World module World World Element abstract class World Structure Array of instances of world elements Contains WorldStructure, Simulator Cable Planet Want to define new operations on all or subset of WorldElement subclass objects Want to define new subclasses of WorldElement calcGrav calcGrav calcGrav Moon calcGrav calcCor calcCor calcCor calcCor Let s look at the class hierarchy for the viewer part of the Space Elevator (SE) s mulator. We have a Wor d class, a Wor dStructure class and an abstract WorldE ement class. A World object conta ns a WorldStructure ob ect and a S mu ator ob ect. WorldE ements can be instantiated as planets, cables, masses, and connectors (spr ngs). If we want to define a new subclass of Wor dElement it is easy to do this, and the subclass will nher t the skeletal imp ementation of the abstract parent class. However, defin ng a new operation for al Wor ements is harder because we have to first provide a skeletal implementation for the abstract class, and then provide mp ementat ons for each of the subclasses. Page 6 67 • • – Visitor Design Pattern Set up WorldElement so arbitrary operations can be added easily World Element Cable Planet abstract class Visitor GravVisitor CorVisitor abstract class Factor out the operations in a separate hierarchy of classes, all extending the abstract class Visitor Each subclass represents one operation Page 7 78 } } • • Visitor (Calculator) Design Pattern World Element Cable Planet Visitor GravVisitor CorVisitor abstract class abstract class Accept(Visitor v) Accept(Visitor v) { v.VisitCable(this); Accept(Visitor v) { v.VisitPlanet(this); VisitCable(Cable c) VisitPlanet(Planet p) VisitCable(Cable c) VisitPlanet(Planet p) VisitCable(Cable c) VisitPlanet(Planet p) Double Dispatching Visitor abstract class can provide skeletal implementation for each WorldElement subclass For example, in a cable, computing the tension in the cable. Then the gravitational force is added to the tension by the GravVisitor subclass. The Coriolis force is added in the CorVisitor subclass. Page 8 89 … … j jj) j) ( j) j j) jj) j j) Double Dispatching WorldElement elm = Visitor vis = elm.Accept(vis); cableOb .Accept(vis) PlanOb .Accept(vis) vis.VisitCable(cableOb vis.VisitPlanet(planObFirst dispatch GravVObj.VisitPlanet planObCorVOb .VisitPlanet(planObGravVOb .VisitCable(cableObCorVOb .VisitCable(cableObSecond dispatch Page 9 910 } } • • Overloading World Element Cable Planet Visitor GravVisitor CorVisitor abstract class abstract class Accept(Visitor v) Accept(Visitor v) { v.Visit(this); Accept(Visitor v) { v.Visit(this); Visit(Cable c) Visit(Planet p) Visit(Cable c) Visit(Planet p) Visit(Cable c) Visit(Planet p) Just syntactic sugar Do not use if you find it confusing! overloading For example, in a cable, computing the tension in the cable. Then the gravitational force is added to the tension by the GravVisitor subclass. The Coriolis force is added in the CorVisitor subclass. Page 10 1011 … … j j( j) ( j) j j) j j) jj) j j) Double Dispatching with Overloading WorldElement elm = Visitor vis = elm.Accept(vis); cableOb .Accept(vis) PlanOb .Accept(vis) vis.Visit cableOb vis.Visit planObFirst dispatch GravVOb .Visit(planObCorVOb .Visit(planObGravVOb .Visit(cableObCorVOb .Visit(cableObSecond dispatch The Java dispatcher will do the right thing when you overload method names. Depending on the argument type, the appropriate method will be called. Page 11 1112 • jjj++) { } } • – each Visitor Usage In the TimeSim simulator module, we can now write code like: for(i = 0; i < WorldStructureOb .Elements.size(); i++) { elm = WorldStructureOb .Elements.get(i); for(j = 0; j < visitorsVector.size(); vis = visitorsVector.get(j); elm.Accept(vis); The above code does not have to change even if we add new WorldElement subclasses or new Visitor subclasses (operations) Need to add visit methods for each new element in Visitor subclass Accept


View Full Document

MIT 6 170 - Space Elevator Simulator

Download Space Elevator Simulator
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Space Elevator Simulator and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Space Elevator Simulator 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?