18.5 Celestial Bodies A simulation of the solar system would contain many different celestial bodies such...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
18.5 Celestial Bodies A simulation of the solar system would contain many different celestial bodies such as stars, planets, or moons. We want to approach the problem of keeping track of these bodies through an object-oriented approach where each body is represented by an instance of class of the type of body. In this problem you will create a base class CelestialBody and derive classes for Planet and Moon from the base class. You will then create instances for planet Earth (a Planet) and its moon Luna (a Moon) and planet Mars (Planet) and its moons Deimos (Moon) and Phobos (Moon). Base class CelestialBody Create a class CelestialBody. It should have the following attributes, which are all initialized with mandatory arguments in the order below when a new instance is created: .name: name of the body position: a numpy array with the three cartesian coordinates in the coordinate system that has the center of mass of the solar system at its origin (solar barycentric"), in astronomic units (AU) mass: mass of the body in kg . radius: approximate radius in km The class should have the following methods: volume(): return the volume of the body (calculated as a sphere from the radius) density(): return the mass density (mass divided by volume) of the body . . delta_r(other): The method takes another Celestial Body (or Planet or Moon) instance as an argument. It calculates and returns the cartesian difference vector (as a numpy array) pointing from itself to the other body. If the position of the body is r = (x, y, z) and the position of the other body is '= (x,y,z) then the difference vector is Ar-r' - r. distance (other): Like delta_r(), the method takes another CelestialBody instance as an argument and returns the distance between the two bodies as a float, . d = Ar. Ar. where the inner product (scalar product or "dot product") between two vectors is used. Derived classes The class Planet should be derived from CelestialBody. Nothing else is required. (Hint: You can always add a pass into the body of the new class definition.) The class Moon should be derived from Celestial Body. It should be initialized with name, position, mass, radius, and the new argument parent.parent should be the planet, represented by a Planet, around which the moon orbits. Moon should have an attribute parent that stores the parent planet. Celestial objects Create the following objects (all data were obtained from the NASA HORIZON system): earth = Planet ("Earth", luna = Moon ("Luna", np. array ([9.978977040419635E-01, 6.586825681892025E-02, -6.320430920521123E-06]), 5.97219e24, 6371.01) name np. array ([9.956768547953816E-01, 6.676030485840675E-02, 1.641093070596718E-04]), 7.349 22, Also create mars and its moons deimos and phobos based on the following table (the radii for the moons are estimates because their actual shape is far from spherical). Note that Mars (as a Planet) does not have a parent so the entry in that column of the table was left empty. 1737.53, earth) Z radius parent "Mars" -1.638989837611019E+00 2.909235766064876E-01 4.607875056151672E-02 6.4171e23 3389.92 "Deimos" -1.638943766241257E+00 2.907775944863155E-01 4.60446557052641 4E-02 1.80e20 29 "Phobos" -1.638995094538730E+00 2.909862261134459E-01 4.608601582090829E-02 1.08e20 24 luna.name Testing The tests test the objects and their methods. For example, the following should work: Name of the Earth's moon: X Distance between Luna and its parent, Earth: luna.distance (luna.parent) Direction from Earth to Mars: earth.delta_r (mars) Density of Phobos and Deimos phobos.density() deimos. density () (Note: we did not do customary unit conversion so the density is in kg/km.) mass mars mars imports and class definitions here if _name__ == "_main__": create your objects here earth Planet ("Earth", np.array([9.978977048419635E-01, 6.586825681892025E-02, -6.320430920521123E-06]), 5.97219024, 6371.01) luna Moon ("Luna", np.array([9.956768547953816E-01, 6.676030485840675E-02, 1.641093070596718E-04]), 7.349e22, 1737.53, earth) # add mars, phobos, delmos here #testing print(luna.name) print(luna.distance(luna.parent)) print(earth.delta_r(nars)) print (phobos.density()) print(deinos.density()) 18.5 Celestial Bodies A simulation of the solar system would contain many different celestial bodies such as stars, planets, or moons. We want to approach the problem of keeping track of these bodies through an object-oriented approach where each body is represented by an instance of class of the type of body. In this problem you will create a base class CelestialBody and derive classes for Planet and Moon from the base class. You will then create instances for planet Earth (a Planet) and its moon Luna (a Moon) and planet Mars (Planet) and its moons Deimos (Moon) and Phobos (Moon). Base class CelestialBody Create a class CelestialBody. It should have the following attributes, which are all initialized with mandatory arguments in the order below when a new instance is created: .name: name of the body position: a numpy array with the three cartesian coordinates in the coordinate system that has the center of mass of the solar system at its origin (solar barycentric"), in astronomic units (AU) mass: mass of the body in kg . radius: approximate radius in km The class should have the following methods: volume(): return the volume of the body (calculated as a sphere from the radius) density(): return the mass density (mass divided by volume) of the body . . delta_r(other): The method takes another Celestial Body (or Planet or Moon) instance as an argument. It calculates and returns the cartesian difference vector (as a numpy array) pointing from itself to the other body. If the position of the body is r = (x, y, z) and the position of the other body is '= (x,y,z) then the difference vector is Ar-r' - r. distance (other): Like delta_r(), the method takes another CelestialBody instance as an argument and returns the distance between the two bodies as a float, . d = Ar. Ar. where the inner product (scalar product or "dot product") between two vectors is used. Derived classes The class Planet should be derived from CelestialBody. Nothing else is required. (Hint: You can always add a pass into the body of the new class definition.) The class Moon should be derived from Celestial Body. It should be initialized with name, position, mass, radius, and the new argument parent.parent should be the planet, represented by a Planet, around which the moon orbits. Moon should have an attribute parent that stores the parent planet. Celestial objects Create the following objects (all data were obtained from the NASA HORIZON system): earth = Planet ("Earth", luna = Moon ("Luna", np. array ([9.978977040419635E-01, 6.586825681892025E-02, -6.320430920521123E-06]), 5.97219e24, 6371.01) name np. array ([9.956768547953816E-01, 6.676030485840675E-02, 1.641093070596718E-04]), 7.349 22, Also create mars and its moons deimos and phobos based on the following table (the radii for the moons are estimates because their actual shape is far from spherical). Note that Mars (as a Planet) does not have a parent so the entry in that column of the table was left empty. 1737.53, earth) Z radius parent "Mars" -1.638989837611019E+00 2.909235766064876E-01 4.607875056151672E-02 6.4171e23 3389.92 "Deimos" -1.638943766241257E+00 2.907775944863155E-01 4.60446557052641 4E-02 1.80e20 29 "Phobos" -1.638995094538730E+00 2.909862261134459E-01 4.608601582090829E-02 1.08e20 24 luna.name Testing The tests test the objects and their methods. For example, the following should work: Name of the Earth's moon: X Distance between Luna and its parent, Earth: luna.distance (luna.parent) Direction from Earth to Mars: earth.delta_r (mars) Density of Phobos and Deimos phobos.density() deimos. density () (Note: we did not do customary unit conversion so the density is in kg/km.) mass mars mars imports and class definitions here if _name__ == "_main__": create your objects here earth Planet ("Earth", np.array([9.978977048419635E-01, 6.586825681892025E-02, -6.320430920521123E-06]), 5.97219024, 6371.01) luna Moon ("Luna", np.array([9.956768547953816E-01, 6.676030485840675E-02, 1.641093070596718E-04]), 7.349e22, 1737.53, earth) # add mars, phobos, delmos here #testing print(luna.name) print(luna.distance(luna.parent)) print(earth.delta_r(nars)) print (phobos.density()) print(deinos.density())
Expert Answer:
Related Book For
Mathematical Interest Theory
ISBN: 9781470465681
3rd Edition
Authors: Leslie Jane, James Daniel, Federer Vaaler
Posted Date:
Students also viewed these programming questions
-
Write an alternative definition that is tail-recursive (iterative) and makes use of accumulator variables. [10 marks] Explain why your alternative definition executes more efficiently. [3 marks] 1...
-
3. Consider the following reaction and kinetic data: 2 HgCl2(aq) + C2O4 (aq) 2 Cl-(aq) + Hg2Cl2(aq) + 2CO2(g) Expt. # [HgC](M) [CO2] (M) Initial rate (Ms) 1 0.10 0.15 1.8 x 10-5 2 0.10 0.30 7.2 x...
-
The adjusted trial balance of Silver Sign Company follows: Requirements 1. Assume Silver Sign Company has a January 31 year end. Journalize Silvers closing entries at January 31. 2. How much net...
-
Natural Step Manufacturing incurred salary expense of $95,000 for September. The company's payroll expense includes CPP of 4.95 percent and EI of 1.4 times the employee payment, which is 1.83 percent...
-
In your own words, explain why the axioms that underlie expected utility are important to decision analysis.
-
Jamie Walker, regional vice president of sales for American Food Processors (AFP), is looking at the performance numbers of his sales force for the past year. He is starting to get that sinking...
-
Your company has received an order for 20 units of a product. The labor cost to produce the item is $9.50 per hour. The setup cost for the item is $60 and material costs are $25 per unit. The item is...
-
There are specific laws that govern aspects of marketing. Please discuss one of those laws and how it might apply to a recent example in the media. What is the law or regulation? What is the case or...
-
Sometimes companies will purchase a booth at a trade show in order to have their sales people discuss what their products or services can do for these potential customers. What this is an example of ?
-
With a quota of 30 tons a month for the Newfoundland cod fishing industry, what is the price of Newfoundland cod fish and the quantity caught? Does overfishing occur? The figure illustrates the...
-
Compare the growth rates in Hong Kong, Korea, Singapore, Taiwan, China, and the United States. In terms of real GDP per person, how far is China behind these others?
-
Describe the procedure to add, modify and delete attributes.
-
Suppose that your mother is a real estate agent, and she has decided to automate her daily tasks using a laptop computer. Consider her potential hardware and software needs, and create a hardware and...
-
If Chris cannot buy cold-summer insurance, what is her expected wealth and what is her expected utility? Chriss wealth is $5,000 and it consists entirely of her share in a risky ice cream business....
-
An order for 100 units of Alpha is scheduled to be shipped at the start of week 9. End item Alpha's product structure tree and inventory information are as follows: LT On-Hand Item Alpha Alpha 15 3....
-
Convert the numeral to a HinduArabic numeral. A94 12
-
Data Set 3 Body Temperatures in Appendix B includes a sample of 106 body temperatures having a mean of 98.20F and a standard deviation of 0.62F. Construct a 95% confidence interval estimate of the...
-
Sydney Smith wrote in On the Conduct of the Understanding that it is impossible to fit a square peg in a round hole. Express the indicated degree of likelihood as a probability value between 0 and 1.
-
Shown below is a histogram of digits selected in California's Win 4 lottery. Each drawing involves the random selection (with replacement) of four digits between 0 and 9 inclusive. a. What is...
-
Do any problems arise when translating physical assets and economic events into monetary units? Give one or two illustrations to support your answer.
-
Entries for the Warren Clinic 2015 income statement are listed below in alphabetical order. Reorder the data in proper format. Depreciation expense General/administrative expenses Interest expense $...
-
Bright Horizons Skilled Nursing Facility, an investor-owned company, constructed a new building to replace its outdated facility. The new building was completed on January 1, 2015, and Bright...
Study smarter with the SolutionInn App