# Okay to post homework # Ryan Badi, April 14 2024, Homework 22 Help := proc(): printf("PlotBodies(t)\nObtain a plot of the sun, moon, and earth at time t to be displayed using Maple's display process.\nUsage: display(PlotBodies(0));\nUse this process for still images.\n\n"): printf("GetBodies()\nObtain an animation object for the sun, moon, and earth to be displayed using Maple's display process.\nUsage: display(GetBodies());\nUse this process for animations.\n"): end: # Tidal Force # We begin with the knowledge that the tidadl force, F, is proportional to M / d^3 where M refers to the mass of the celestial body and d refers to the distance between its center and earth's. # Because the moon's tidal force is stronger than the sun's, we have that F_m / F_s > 1. # Also known to us due to trigonometric identities is that d = R / t where R is the radius of the celestial body and t is the angle we observe on earth. # Substituting, we have that (M_m / d_m^3) / (M_s / d_s^3) = (M_m / R_m^3) / (M_s / R_s^3) > 1. # Known to us due to geometry is that V = 4 / 3 * Pi * R^3 where V is the volume of the clestial body. # Also known is that p = M/V where p is the densityof the celestial body. # Substituing further, we have that (M_m / R_m^3) / (M_s / R_s^3) = (M_m / V_m) / (M_s / V_s) = p_m / p_s > 1. # Thus, we have proven that the moon is more dense than the sun. # Project Progress # So far, we have created a function to generate anagrams given a database, and we have also added two databases. We still need to create the functionality to interface with the user properly. # The project and any further progress can be found here: https://github.com/AlexV-01/anagram-puzzle-book with(plots): trueToScale := false: # Set this to true if a realistic scale is desired. Doing so will result in an image that is difficult to see. sunCenterX := proc(t): return 0: end: sunCenterY := proc(t): return 0: end: earthCenterX := proc(t): return bodies["sun"]["distance"]*cos(t): end: earthCenterY := proc(t): return bodies["sun"]["distance"]*sin(t): end: moonCenterX := proc(t): return earthCenterX(t) + bodies["moon"]["distance"]*cos(365*t): end: moonCenterY := proc(t): return earthCenterY(t) + bodies["moon"]["distance"]*sin(365*t): end: bodies := table(["sun" = table(["radius" = 696.*10^3, "distance" = 149.6*10^6, "centerX" = sunCenterX, "centerY" = sunCenterY, "color" = "yellow"]), "earth" = table(["radius" = 6378.1, "distance" = 0, "centerX" = earthCenterX, "centerY" = earthCenterY, "color" = "blue"]), "moon" = table(["radius" = 1737., "distance" = 384400., "centerX" = moonCenterX, "centerY" = moonCenterY, "color" = "gray"])]): if trueToScale = false then: bodies["sun"]["radius"] := bodies["sun"]["radius"] / 25: bodies["sun"]["distance"] := bodies["sun"]["distance"] / 625: bodies["moon"]["radius"] := bodies["moon"]["radius"]: bodies["moon"]["distance"] := bodies["moon"]["distance"] / 25: fi: GetBody := proc(body, t): return [body["centerX"](t) + body["radius"]*cos(l), body["centerY"](t) + body["radius"]*sin(l), l=0..2*Pi], axes=none, filled=true, color=body["color"], scaling=constrained: end: GetEarthOrbit := proc(): return [bodies["sun"]["distance"]*cos(l), bodies["sun"]["distance"]*sin(l), l=0..2*Pi], axes=none, filled=false, color="blue", scaling=constrained: end: GetMoonOrbit := proc(t): return [earthCenterX(t) + bodies["moon"]["distance"]*cos(l), earthCenterY(t) + bodies["moon"]["distance"]*sin(l), l=0..2*Pi], axes=none, filled=false, color="gray", scaling=constrained: end: PlotBodies := proc(t) local container: container := plot(GetBody(bodies["sun"], t)): container := container, plot(GetBody(bodies["earth"], t)): container := container, plot(GetBody(bodies["moon"], t)): container := container, plot(GetEarthOrbit()): container := container, plot(GetMoonOrbit(t)): container := container, textplot([0, 0, "S"]): container := container, textplot([earthCenterX(t), earthCenterY(t), "E"]): container := container, textplot([moonCenterX(t), moonCenterY(t), "M"]): return container: end: GetBodies := proc(): return [animate(plot, [GetBody(bodies["sun"], t)], t=0..2*Pi, frames=180), animate(plot, [GetBody(bodies["earth"], t)], t=0..2*Pi, frames=180), animate(plot, [GetBody(bodies["moon"], t)], t=0..2*Pi, frames=180), animate(plot, [GetEarthOrbit()], t=0..2*Pi, frames=180), animate(plot, [GetMoonOrbit(t)], t=0..2*Pi, frames=180), animate(textplot, [[0, 0, "S"]], t=0..2*Pi, frames=180), animate(textplot, [[earthCenterX(t), earthCenterY(t), "E"]], t=0..2*Pi, frames=180), animate(textplot, [[moonCenterX(t), moonCenterY(t), "M"]], t=0..2*Pi, frames=180)]: end: