Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 10.2' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[

(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 10.2' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 158, NotebookDataLength[ 35433, NotebookOptionsPosition[ 34766, NotebookOutlinePosition[ 35157, CellTagsIndexPosition[ 35114, WindowFrame->Normal*) 7] 797] 771] 788] 785] (* Beginning of Notebook Content *) Notebook[{ Cell["\\<\\ CPI 200: Math Foundations of Informatics \\[LineSeparator]Instructor: \\ Dianne Hansford Homework #2: -- Barycentric coordinates -- Spherical Coordinates and Curves on a Surfaces Due: Feb 16 by midnight\\ \\>", "Subsection", CellChangeTimes->{{3.663529628430106*^9, 3.6635296566057177`*^9}, { 3.6635296881895237`*^9, 3.6635297465918646`*^9}, {3.6635306019147863`*^9, 3.6635306296933746`*^9}, {3.663534326583825*^9, 3.66353436356194*^9}, { 3.6952123690617123`*^9, 3.695212458941843*^9}, {3.695215585574958*^9, 3.695215594554971*^9}, {3.6952173785319996`*^9, 3.6952173958170524`*^9}, { 3.695298254729683*^9, 3.6952982552096834`*^9}}], Cell[TextData[{ StyleBox["Guidelines:", FontWeight->"Bold"], "\ Turn in via Blackboard\ Name your file lastnameFirstInitial_HW2.nb\ Below \\ each problem description, add your MM code\ Comment your notebook\ Work \\ independently" }], "Subsection", CellChangeTimes->{{3.663529628430106*^9, 3.6635296566057177`*^9}, { 3.6635296881895237`*^9, 3.6635297465918646`*^9}, {3.6635306967522106`*^9, 3.663530707218809*^9}, {3.663530753724469*^9, 3.663530800041118*^9}, { 3.663530856703359*^9, 3.6635308683380246`*^9}, {3.6952124699238586`*^9, 3.6952124808118753`*^9}}], Cell["\\<\\ Grading Part 1: 40 Part 2: 40 Part 3: 20\\ \\>", "Subsection", CellChangeTimes->{{3.695302752963437*^9, 3.6953028035035086`*^9}}, Background->RGBColor[1, 0.925, 0.925]], Cell[CellGroupData[{ Cell[TextData[{ "\ PART 1. ", StyleBox["Barycentric coordinates of a point with respect to a triangle\ In \\ this section, we plot a colored 2d triangle and its vertices, colored with \\ distinct colors.\ A 2d slider allows the user to move a point in the \\ xy-plane.\ The barycentric coordinates of this (x,y) point are computed and \\ displayed.\ The moving point changes color; its color is computed as linear \\ interpolation of the vertex colors.\ \ I have supplied code snippets. You \\ must complete the code to satisfy the functionality described above.\ I have \\ indicated what you have to do with \\[OpenCurlyDoubleQuote]To Do\\ \\[CloseCurlyDoubleQuote] comments.\ ", FontFamily->"Gill Sans MT"] }], "Subtitle", CellChangeTimes->{{3.6635267194027195`*^9, 3.663526728399234*^9}, { 3.663526775619934*^9, 3.6635267759329524`*^9}, {3.6635268320791636`*^9, 3.663526834549305*^9}, {3.6635270906159515`*^9, 3.663527098583407*^9}, { 3.6635309036730456`*^9, 3.663530905091127*^9}, {3.6635309821945367`*^9, 3.663531049960413*^9}, {3.663531102945443*^9, 3.663531155735463*^9}, { 3.6635311901764326`*^9, 3.6635311958357563`*^9}, {3.6635312385281982`*^9, 3.6635312832217546`*^9}, {3.6635313165806627`*^9, 3.6635313395879784`*^9}, {3.6635315809457836`*^9, 3.6635315868571215`*^9}, {3.6635317217898393`*^9, 3.6635317245769987`*^9}, {3.663532559838773*^9, 3.663532657432355*^9}, { 3.6635328235048532`*^9, 3.6635328273970766`*^9}, {3.6635329634348574`*^9, 3.663532988144271*^9}, {3.6635330187940235`*^9, 3.663533033747879*^9}, { 3.6635330694969234`*^9, 3.663533097340516*^9}, {3.663533131006442*^9, 3.663533382792843*^9}, {3.66353420621494*^9, 3.6635342480703344`*^9}, { 3.6952125135719233`*^9, 3.695212517071928*^9}, 3.695215568979404*^9, { 3.6952156050069857`*^9, 3.695215659574063*^9}, 3.6952157519205327`*^9, { 3.695216440603059*^9, 3.6952166026222982`*^9}, {3.695216633314842*^9, 3.6952167131924553`*^9}, {3.6952167656700296`*^9, 3.6952167905461774`*^9}, {3.6952983281020145`*^9, 3.6952983621674557`*^9}, {3.6952984157226467`*^9, 3.6952984414259615`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"(*", " ", RowBox[{"Triangle", " ", "vertices"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"v1", " ", "=", " ", RowBox[{"{", RowBox[{ RowBox[{"-", "2.0"}], ",", RowBox[{"-", "2.0"}]}], "}"}]}], ";"}], "\\[IndentingNewLine]", RowBox[{ RowBox[{"v2", " ", "=", " ", RowBox[{"{", RowBox[{"2.0", ",", RowBox[{"-", "2.0"}]}], "}"}]}], ";"}], "\\[IndentingNewLine]", RowBox[{ RowBox[{"v3", " ", "=", " ", RowBox[{"{", RowBox[{"0.0", ",", " ", "2.0"}], "}"}]}], ";"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"xy", "-", RowBox[{"space", " ", "to", " ", "plot"}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{ RowBox[{"range", " ", "=", " ", "4"}], ";"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Set", " ", "vertex", " ", "colors"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"TO", " ", RowBox[{"DO", ":", " ", RowBox[{"Pick", " ", "three", " ", "distinct", " ", "colors"}]}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{ RowBox[{"c1", " ", "=", " ", RowBox[{"{", RowBox[{"1", ",", "0", ",", "0"}], "}"}]}], ";"}], " ", RowBox[{"(*", " ", "RED", " ", "*)"}], "\\[IndentingNewLine]", RowBox[{ RowBox[{"c2", " ", "=", " ", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0"}], "}"}]}], ";"}], RowBox[{"(*", " ", "GREEN", " ", "*)"}], "\\[IndentingNewLine]", RowBox[{ RowBox[{"c3", " ", "=", " ", RowBox[{"{", RowBox[{"0", ",", "0", ",", "1"}], "}"}]}], ";"}], " ", RowBox[{"(*", "BLUE", "*)"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{ "Compute", " ", "the", " ", "barycentric", " ", "coordiantes", " ", "of", " ", "a", " ", "2", "d", " ", "point", " ", "xy", " ", "based", " ", "on", " ", "triangle", " ", "vertices", " ", "v1"}], ",", " ", "v2", ",", " ", "v3"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{ RowBox[{"Input", ":", " ", "xy"}], " ", "=", " ", RowBox[{ RowBox[{"{", RowBox[{"x", ",", "y"}], "}"}], " ", "and", " ", "global", " ", "v1"}]}], ",", " ", "v2", ",", " ", RowBox[{"v2", " ", "each", " ", "as", " ", RowBox[{"{", RowBox[{"x", ",", "y"}], "}"}]}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"Output", ":", " ", "uvw"}], " ", "=", " ", RowBox[{ RowBox[{"{", RowBox[{"u", ",", "v", ",", "w"}], "}"}], " ", "barycentric", " ", "coordinates"}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"TO", " ", RowBox[{"DO", ":", " ", RowBox[{"Complete", " ", "this", " ", RowBox[{"route", ".", " ", "Hint"}]}], ":", " ", RowBox[{"Use", " ", "LinearSolve"}]}]}], " ", "*)"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"computeBaryCoords", "[", "xy_", "]"}], ":=", " ", RowBox[{"(", "\\[IndentingNewLine]", " ", "\\[IndentingNewLine]", RowBox[{"Return", "[", "uvw", "]"}], "\\[IndentingNewLine]", ")"}]}], ";"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]", "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "Compute", " ", "the", " ", "color", " ", "of", " ", "a", " ", "point", " ", "in", " ", "a", " ", "triangle", " ", "as", " ", "linear", " ", "interpolation", " ", "to", " ", "the", " ", "colors", " ", "at", " ", "the", " ", "vertices"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{ RowBox[{"Input", ":", " ", "uvw"}], " ", "=", " ", RowBox[{ RowBox[{"{", RowBox[{"u", ",", "v", ",", "w"}], "}"}], " ", "and", " ", "global", " ", "c1"}]}], ",", " ", "c2", ",", " ", RowBox[{"c3", " ", "each", " ", "as", RowBox[{"{", RowBox[{"r", ",", "g", ",", "b"}], "}"}], " ", "colors"}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Output", ":", " ", RowBox[{"color", " ", RowBox[{"{", RowBox[{"r", ",", "g", ",", "b"}], "}"}]}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"TO", " ", RowBox[{"DO", ":", " ", RowBox[{"Compute", " ", "the", " ", "color"}]}]}], " ", "*)"}], "\\[IndentingNewLine]", " ", RowBox[{ RowBox[{ RowBox[{"computeColor", "[", "uvw_", "]"}], " ", ":=", " ", RowBox[{"Return", "[", " ", RowBox[{"(*", " ", RowBox[{"calculate", " ", "color", " ", "here"}], " ", "*)"}], "]"}]}], ";"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]", "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "Create", " ", "graphics", " ", "entitiy", " ", "for", " ", "triangle", " ", "and", " ", "vertices"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{ RowBox[{"plotTriangle", " ", "=", " ", RowBox[{"Graphics", "[", RowBox[{ RowBox[{"{", RowBox[{"Yellow", ",", RowBox[{"Polygon", "[", RowBox[{"{", RowBox[{"v1", ",", "v2", ",", "v3"}], "}"}], "]"}], ",", RowBox[{"PointSize", "[", "Large", "]"}], ",", RowBox[{"RGBColor", "[", "c1", "]"}], ",", RowBox[{"Point", "[", "v1", "]"}], ",", " ", RowBox[{"RGBColor", "[", "c2", "]"}], ",", RowBox[{"Point", "[", "v2", "]"}], ",", RowBox[{"RGBColor", "[", "c3", "]"}], ",", RowBox[{"Point", "[", "v3", "]"}]}], "}"}], ",", RowBox[{"Axes", "\\[Rule]", "True"}], ",", " ", RowBox[{"PlotRange", "\\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "range"}], ",", "range"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "range"}], ",", "range"}], "}"}]}], "}"}]}]}], "]"}]}], ";"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "Let", " ", "a", " ", "point", " ", "xy", " ", "move", " ", "about", " ", "in", " ", "the", " ", "space", " ", "defined", " ", "by", " ", "range"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "Display", " ", "the", " ", "barycentric", " ", "coordinates", " ", "of", " ", "the", " ", "point"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "Color", " ", "the", " ", "point", " ", "xy", " ", "as", " ", "the", " ", "linear", " ", "interpolant", " ", "to", " ", "the", " ", "colors", " ", "at", " ", "the", " ", "vertices"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"TO", " ", RowBox[{"DO", ":", " ", RowBox[{ "Once", " ", "you", " ", "get", " ", "the", " ", "routines", " ", "above", " ", "working"}]}]}], ",", " ", RowBox[{ "this", " ", "Manipulate", " ", "should", " ", "work", " ", "as", " ", RowBox[{"is", "."}]}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Do", " ", "NOT", " ", "start", " ", "with", " ", RowBox[{ RowBox[{"Manipulate", "!!"}], "!"}], " ", "First", " ", "get", " ", "your", " ", "code", " ", "working", " ", "outside", " ", "of", " ", "this", " ", "environment"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", "\\[IndentingNewLine]", RowBox[{"Manipulate", "[", " ", RowBox[{ RowBox[{"(", "\\[IndentingNewLine]", RowBox[{ RowBox[{"uvw", " ", "=", " ", RowBox[{"computeBaryCoords", "[", "xy", "]"}]}], ";", "\\[IndentingNewLine]", RowBox[{"rgb", " ", "=", " ", RowBox[{"computeColor", "[", "uvw", "]"}]}], ";", "\\[IndentingNewLine]", RowBox[{"plotPoint", " ", "=", " ", RowBox[{"Graphics", "[", RowBox[{"{", " ", RowBox[{ RowBox[{"RGBColor", "[", RowBox[{ RowBox[{"rgb", "[", RowBox[{"[", "1", "]"}], "]"}], ",", " ", RowBox[{"rgb", "[", RowBox[{"[", "2", "]"}], "]"}], ",", " ", RowBox[{"rgb", "[", RowBox[{"[", "3", "]"}], "]"}]}], "]"}], ",", RowBox[{"PointSize", "[", "0.05", "]"}], ",", RowBox[{"Point", "[", "xy", "]"}]}], "}"}], "]"}]}], ";", "\\[IndentingNewLine]", RowBox[{"plotBaryCoords", " ", "=", " ", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{"Black", ",", " ", RowBox[{"Text", "[", RowBox[{ RowBox[{"Style", "[", RowBox[{"\\"\\\\"", ",", RowBox[{"FontSize", "\\[Rule]", "15"}]}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "4"}], "}"}], ",", RowBox[{"Scaled", "[", RowBox[{"{", RowBox[{"1", ",", "1"}], "}"}], "]"}]}], "]"}], ",", RowBox[{"Text", "[", RowBox[{ RowBox[{"Style", "[", RowBox[{ RowBox[{"NumberForm", "[", RowBox[{"uvw", ",", "2"}], "]"}], ",", RowBox[{"FontSize", "\\[Rule]", "15"}]}], "]"}], ",", RowBox[{"{", RowBox[{"4", ",", "4"}], "}"}], ",", RowBox[{"Scaled", "[", RowBox[{"{", RowBox[{"1", ",", "1"}], "}"}], "]"}]}], "]"}]}], "}"}], "]"}]}], ";", "\\[IndentingNewLine]", " ", RowBox[{"Show", "[", RowBox[{"{", RowBox[{ "plotTriangle", ",", " ", "plotPoint", ",", "plotBaryCoords"}], "}"}], "]"}]}], ")"}], ",", "\\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"xy", ",", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}]}], "}"}], ",", " ", RowBox[{"{", RowBox[{ RowBox[{"-", "range"}], ",", RowBox[{"-", "range"}]}], "}"}], ",", RowBox[{"{", RowBox[{"range", ",", "range"}], "}"}]}], "}"}]}], "]"}], "\\[IndentingNewLine]", "*)"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]"}]}]], "Input", CellChangeTimes->{{3.663533428475456*^9, 3.663533477416255*^9}, 3.6635335110151772`*^9, {3.6635335448731136`*^9, 3.663533548592326*^9}, { 3.6635335918328*^9, 3.6635336052235656`*^9}, {3.663533787675001*^9, 3.6635338187007756`*^9}, {3.663533863095315*^9, 3.663533877651148*^9}, 3.663533911009055*^9, {3.6635339663472204`*^9, 3.663533976269788*^9}, { 3.6635340532681923`*^9, 3.663534169300829*^9}, {3.6952125545753736`*^9, 3.695212706162071*^9}, {3.695213197283849*^9, 3.695213397810835*^9}, { 3.695213487402133*^9, 3.6952134990931497`*^9}, {3.69521354015399*^9, 3.6952136943573785`*^9}, {3.6952137402569714`*^9, 3.6952139206498194`*^9}, {3.6952139524669514`*^9, 3.6952139586479864`*^9}, {3.695214027370392*^9, 3.695214215991028*^9}, { 3.695214253660081*^9, 3.6952143014541492`*^9}, {3.695214376907901*^9, 3.69521438600919*^9}, {3.6952144237752433`*^9, 3.6952145327765126`*^9}, { 3.695214565681571*^9, 3.6952146149889717`*^9}, 3.6952146465238514`*^9, { 3.6952147072741113`*^9, 3.6952148028042774`*^9}, {3.6952148824160333`*^9, 3.6952148903250446`*^9}, {3.695215002297847*^9, 3.6952150805440073`*^9}, { 3.6952151178210955`*^9, 3.6952151416851315`*^9}, {3.69521520921268*^9, 3.6952153048624334`*^9}, {3.695215451557367*^9, 3.6952154640673847`*^9}, { 3.695215540774337*^9, 3.695215548740375*^9}, {3.6952158156339016`*^9, 3.695216020977419*^9}, {3.695216189517686*^9, 3.6952162840543003`*^9}, { 3.6952163141343427`*^9, 3.695216399967081*^9}, {3.6952167247024713`*^9, 3.695216760585022*^9}, {3.6952172123757334`*^9, 3.695217226070753*^9}, { 3.6952172644171133`*^9, 3.695217269173233*^9}, {3.695219539243452*^9, 3.695219543893459*^9}, {3.695298464167107*^9, 3.6952990756463113`*^9}, { 3.695299126416662*^9, 3.6952991265166616`*^9}, {3.6953016622189937`*^9, 3.6953016780015163`*^9}, {3.695301720040354*^9, 3.6953017680604506`*^9}, { 3.6953018050155025`*^9, 3.6953018115655117`*^9}, {3.6953018609905815`*^9, 3.6953018712705965`*^9}, {3.6953019237782836`*^9, 3.6953019459733157`*^9}, {3.6953020062959013`*^9, 3.695302047388488*^9}, { 3.696278941839797*^9, 3.696278990008861*^9}, {3.6962820087271757`*^9, 3.696282016956882*^9}}] }, Open ], Cell[CellGroupData[{ Cell[TextData[{ "\ Part 2. Spherical Coordinates and Curves on Surfaces\ Here we use the \\ (r, theta, phi) parametrization of the sphere in Chapter 3, slide 11. The \\ domain is defined on slide 9.\ \ Plot a radius=1 sphere, making it \\ transparent.\ Add the north pole as a blue point and the south pole as a \\ green point.\ Add the equator as a red curve.\ \ Map the parametric spiral \ \\ {t*Cos[4*t], t*Sin[4*t]} for t in [0, 2Pi]\ to live in the (theta, phi) \\ domain of the sphere. The curve must fill the entire domain.\ Plot this 2d \\ parametric curve. \ Plot the spiral on the sphere.\ \ ", StyleBox["I have supplied code snippets. You must complete the code to \\ satisfy the functionality described above.\ I have indicated what you have to \\ do with \\[OpenCurlyDoubleQuote]To Do\\[CloseCurlyDoubleQuote] comments.", FontFamily->"Gill Sans MT"] }], "Subtitle", CellChangeTimes->{{3.6821992311118774`*^9, 3.6821992545912204`*^9}, { 3.6821993401411133`*^9, 3.682199461502055*^9}, {3.6821995804678593`*^9, 3.6821996069933767`*^9}, {3.6821997309014635`*^9, 3.6821997421181054`*^9}, { 3.6822004706067724`*^9, 3.682200523149778*^9}, {3.682201534780348*^9, 3.682201594555767*^9}, {3.6822016286787186`*^9, 3.682201639821356*^9}, { 3.6822016883661327`*^9, 3.682201702885963*^9}, {3.6822017835815783`*^9, 3.6822018161364403`*^9}, {3.6822021535487394`*^9, 3.682202168893617*^9}, { 3.695217357881971*^9, 3.695217368181985*^9}, {3.695217403097063*^9, 3.695217403177063*^9}, {3.695217560942874*^9, 3.6952175660328813`*^9}, { 3.695249424712229*^9, 3.695249425272229*^9}, {3.695299195412874*^9, 3.695299236304741*^9}, {3.6952992691988163`*^9, 3.69529950343027*^9}, { 3.695299822798256*^9, 3.695299960064867*^9}, {3.6953002625175443`*^9, 3.695300279461569*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"(*", " ", RowBox[{"radius", " ", "of", " ", "the", " ", "sphere"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"r", " ", "=", " ", "1.0"}], ";"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]", "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"calculate", " ", "an", " ", "x"}], ",", "y", ",", RowBox[{ "z", " ", "point", " ", "on", " ", "a", " ", "sphere", " ", "given", " ", "parameters", " ", "r"}], ",", " ", "theta", ",", " ", "phi"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"TO", " ", RowBox[{"DO", ":", " ", RowBox[{ "Implement", " ", "the", " ", "parametric", " ", "sphere", " ", "equation"}]}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{ RowBox[{"spherept", "[", RowBox[{"r_", ",", " ", "theta_", ",", " ", "phi_"}], "]"}], " ", ":=", " ", RowBox[{"r", "*", RowBox[{"{", " ", "}"}]}]}], ";"}], " ", "*)"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]", "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "Construct", " ", "Equator", " ", "as", " ", "line", " ", "in", " ", "domain", " ", "of", " ", "sphere"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"TO", " ", RowBox[{"DO", ":", " ", RowBox[{ "Create", " ", "an", " ", "equation", " ", "of", " ", "a", " ", "line", " ", "in", " ", "the", " ", "domain", " ", "corresponding", " ", "to", " ", "the", " ", RowBox[{"equator", "."}]}]}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{ RowBox[{"equatorLine", "[", "t_", "]"}], " ", ":=", " ", RowBox[{"your", " ", "code", " ", "here"}]}], ";"}], " ", "*)"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Equator", " ", "CONS"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Input", ":", " ", RowBox[{ "t", " ", "parameter", " ", "for", " ", "equator", " ", "line"}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Output", ":", " ", RowBox[{ RowBox[{"{", RowBox[{"x", ",", "y", ",", "z"}], "}"}], " ", "on", " ", "sphere"}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{ "t", " ", "value", " ", "generates", " ", "a", " ", "point", " ", "on", " ", "a", " ", "2", "d", " ", RowBox[{"line", ".", " ", "These"}], " ", "coordinates", " ", "are", " ", RowBox[{"(", RowBox[{"theta", ",", " ", "phi"}], ")"}]}], ",", " ", RowBox[{ "defining", " ", "a", " ", "point", " ", "on", " ", "the", " ", "sphere"}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"TO", " ", RowBox[{"DO", ":", " ", RowBox[{"Complete", " ", "the", " ", "routine"}]}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", "\\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"equatorLineCons", "[", "t_", "]"}], " ", ":=", RowBox[{"(", "\\[IndentingNewLine]", "\\[IndentingNewLine]", ")"}]}], ";"}], "\\[IndentingNewLine]", "*)"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Spiral", " ", "is", " ", RowBox[{"{", RowBox[{ RowBox[{"t", "*", RowBox[{"Cos", "[", RowBox[{"4", "*", "t"}], "]"}]}], ",", " ", RowBox[{"t", "*", RowBox[{"Sin", "[", RowBox[{"4", "*", "t"}], "]"}]}]}], "}"}], " ", "for", " ", "t", " ", RowBox[{"in", " ", "[", RowBox[{"0", ",", " ", RowBox[{"2", "Pi"}]}], "]"}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "Spiral", " ", "is", " ", "mapped", " ", "to", " ", "the", " ", "domain", " ", "of", " ", "the", " ", RowBox[{"sphere", ":", " ", RowBox[{ RowBox[{"[", RowBox[{"0", ",", RowBox[{"2", "Pi"}]}], "]"}], RowBox[{"x", "[", RowBox[{"0", ",", " ", "Pi"}], "]"}]}]}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"TO", " ", RowBox[{"DO", ":", " ", RowBox[{ "Modify", " ", "the", " ", "spiral", " ", "to", " ", "live", " ", "in", " ", "the", " ", "sphere", " ", RowBox[{"domain", "."}]}]}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "You", " ", "need", " ", "to", " ", "scale", " ", "and", " ", "translate", " ", "the", " ", "coordinates"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "Try", " ", "plotting", " ", "it", " ", "as", " ", "it", " ", "is", " ", "to", " ", "figure", " ", "out", " ", "what", " ", "you", " ", "need", " ", "to", " ", RowBox[{"do", "."}]}], "*)"}], "\\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"spiral", "[", "t_", "]"}], " ", ":=", " ", RowBox[{"{", RowBox[{ RowBox[{"t", "*", RowBox[{"Cos", "[", RowBox[{"4", "*", "t"}], "]"}]}], ",", " ", RowBox[{"t", "*", RowBox[{"Sin", "[", RowBox[{"4", "*", "t"}], "]"}]}]}], "}"}]}], " ", ";"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]", "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Curve", " ", "on", " ", "Surface"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Input", ":", " ", RowBox[{"parameter", " ", "t", " ", "on", " ", "spiral"}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "Use", " ", "spiral", " ", "point", " ", "to", " ", "generate", " ", "theta", " ", "and", " ", "phi", " ", "use", " ", "these", " ", "to", " ", "generate", " ", "a", " ", "point", " ", "on", " ", "the", " ", "sphere"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"TO", " ", RowBox[{"DO", ":", " ", RowBox[{"Complete", " ", "this", " ", "code"}]}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", "\\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"cons", "[", "t_", "]"}], " ", ":=", " ", RowBox[{"(", "\\[IndentingNewLine]", "\\[IndentingNewLine]", ")"}]}], ";"}], "\\[IndentingNewLine]", "*)"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]", RowBox[{"(*", " ", "GRAPHICS", " ", "*)"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Plot", " ", "curve", " ", "in", " ", "domain"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"Sphere", " ", "domain", " ", "is", " ", RowBox[{"roughly", " ", "[", RowBox[{"0", ",", "6"}], "]"}], " ", RowBox[{"x", " ", "[", RowBox[{"0", ",", "3"}], "]"}]}], ",", " ", RowBox[{ "so", " ", "curve", " ", "should", " ", "live", " ", "in", " ", "that", " ", "space"}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"ParametricPlot", "[", RowBox[{ RowBox[{"spiral", "[", "t", "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", RowBox[{"2", "Pi"}]}], "}"}]}], "]"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Create", " ", "graphics", " ", "objects"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"TO", " ", RowBox[{"DO", ":", " ", RowBox[{"put", " ", "appropriate", " ", "coordinates", " ", "in", " ", RowBox[{"Point", "[", "]"}], " ", "for", " ", "North", " ", "and", " ", "South"}]}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"plotNorthPole", " ", "=", " ", RowBox[{"Graphics3D", "[", RowBox[{"{", RowBox[{"Blue", ",", " ", RowBox[{"PointSize", "[", "0.05", "]"}], ",", " ", RowBox[{"Point", "[", RowBox[{"spherept", "[", " ", "]"}], "]"}]}], "}"}], "]"}]}], ";"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"plotSouthPole", " ", "=", " ", RowBox[{"Graphics3D", "[", RowBox[{"{", RowBox[{"Green", ",", " ", RowBox[{"PointSize", "[", "0.05", "]"}], ",", " ", RowBox[{"Point", "[", RowBox[{"spherept", "[", "]"}], "]"}]}], "}"}], "]"}]}], ";"}], " ", "*)"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "The", " ", "next", " ", "two", " ", "plots", " ", "are", " ", "ready", " ", "to", " ", "use", " ", "once", " ", "you", " ", "have", " ", "written", " ", "the", " ", "routines"}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"plotEquatorCons", " ", "=", " ", RowBox[{"ParametricPlot3D", "[", RowBox[{ RowBox[{"equatorLineCons", "[", "t", "]"}], ",", " ", RowBox[{"{", RowBox[{"t", ",", "0", ",", "1"}], "}"}], ",", " ", RowBox[{"PlotStyle", "\\[Rule]", RowBox[{"{", RowBox[{"Red", ",", "Thick"}], "}"}]}]}], "]"}]}], ";"}], " ", "*)"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"plotcons", " ", "=", " ", RowBox[{"ParametricPlot3D", "[", RowBox[{ RowBox[{"cons", "[", "t", "]"}], ",", " ", RowBox[{"{", RowBox[{"t", ",", "0", ",", RowBox[{"2", "Pi"}]}], "}"}], ",", " ", RowBox[{"PlotStyle", "\\[Rule]", RowBox[{"{", RowBox[{"Cyan", ",", "Thick"}], "}"}]}]}], "]"}]}], ";"}], " ", "*)"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]", RowBox[{ RowBox[{"plotsphere", " ", "=", " ", RowBox[{"Graphics3D", "[", RowBox[{"{", RowBox[{"LightBlue", ",", RowBox[{"Opacity", "[", "0.5", "]"}], ",", RowBox[{"Sphere", "[", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0", ",", "0"}], "}"}], ",", " ", "r"}], "]"}]}], "}"}], "]"}]}], ";"}], "\\[IndentingNewLine]", "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"plot", " ", "together"}], ";", " ", RowBox[{ "sphere", " ", "needs", " ", "to", " ", "be", " ", "listed", " ", "first", " ", "so", " ", "full", " ", "range", " ", "of", " ", "plot", " ", "is", " ", "shown"}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"TO", " ", RowBox[{"DO", ":", " ", RowBox[{ "Add", " ", "the", " ", "plots", " ", "once", " ", "you", " ", "have", " ", "created", " ", "them"}]}]}], " ", "*)"}], "\\[IndentingNewLine]", RowBox[{"Show", "[", RowBox[{"{", " ", "plotsphere", " ", RowBox[{"(*", RowBox[{ ",", "plotcons", ",", "plotEquatorCons", ",", " ", "plotNorthPole", ",", " ", "plotSouthPole"}], "*)"}], "}"}], "]"}], "\\[IndentingNewLine]"}]}]], "Input", CellChangeTimes->{{3.682199471570631*^9, 3.6821995576525545`*^9}, { 3.682199746288344*^9, 3.6821998239227843`*^9}, {3.6821998657301755`*^9, 3.682199887254407*^9}, {3.682199931488937*^9, 3.6821999438866463`*^9}, { 3.682200025940339*^9, 3.6822000470425463`*^9}, {3.6822000796764126`*^9, 3.6822000883279076`*^9}, {3.6822001602510214`*^9, 3.6822001615160933`*^9}, {3.682200206161647*^9, 3.6822003400973077`*^9}, { 3.6822003705820513`*^9, 3.6822003929473305`*^9}, {3.6822004413851013`*^9, 3.6822004448362985`*^9}, {3.6822005952589025`*^9, 3.6822006461228113`*^9}, {3.682200745507496*^9, 3.6822008188436904`*^9}, { 3.6822008589329834`*^9, 3.6822008594770145`*^9}, {3.682200922419615*^9, 3.682201060794529*^9}, {3.682201123886138*^9, 3.682201126611294*^9}, { 3.6822012367855954`*^9, 3.6822013010802727`*^9}, {3.682201691042286*^9, 3.6822016995397716`*^9}, {3.6822018499793763`*^9, 3.6822021429891357`*^9}, {3.695218170785183*^9, 3.6952181772126923`*^9}, { 3.6952182521477976`*^9, 3.695218281557867*^9}, {3.6952183222654247`*^9, 3.695218351475466*^9}, {3.6952183995718117`*^9, 3.6952185440734096`*^9}, { 3.6952185757359543`*^9, 3.6952185853559675`*^9}, {3.695218715989765*^9, 3.6952187227497745`*^9}, {3.695218761308668*^9, 3.695218794932522*^9}, { 3.6952188339002466`*^9, 3.6952188376802516`*^9}, {3.6952188730479145`*^9, 3.695218922367984*^9}, {3.6952191042508535`*^9, 3.6952191066008563`*^9}, { 3.695219271916765*^9, 3.695219472513302*^9}, {3.695219591641026*^9, 3.6952196298686934`*^9}, {3.6952196627112675`*^9, 3.6952196733587823`*^9}, {3.695219709311333*^9, 3.6952197443390236`*^9}, { 3.695219816949154*^9, 3.69521981997116*^9}, {3.695246993009411*^9, 3.6952469954194145`*^9}, {3.6952470297344656`*^9, 3.6952472019063883`*^9}, {3.6952472326384335`*^9, 3.695247341103595*^9}, { 3.695247404194687*^9, 3.6952474128087*^9}, {3.6952474729033165`*^9, 3.6952474855833344`*^9}, {3.695247522218502*^9, 3.695247537292637*^9}, { 3.695247570083685*^9, 3.695247617183754*^9}, {3.695247660333346*^9, 3.695247672056363*^9}, {3.695248298488288*^9, 3.6952483152953124`*^9}, { 3.695248369611392*^9, 3.6952483787744055`*^9}, {3.6952484624936695`*^9, 3.6952484635836716`*^9}, {3.6952486065629063`*^9, 3.695248704125052*^9}, { 3.695248777751159*^9, 3.6952488943503866`*^9}, {3.6952490007767687`*^9, 3.6952490134127865`*^9}, 3.695249118990612*^9, {3.69524915371819*^9, 3.695249155911194*^9}, {3.6952491949072514`*^9, 3.695249272168892*^9}, { 3.69524935975902*^9, 3.6952493794480486`*^9}, 3.6952494944233294`*^9, 3.6952495738107243`*^9, {3.695299628983132*^9, 3.6952996944216175`*^9}, { 3.695299724630304*^9, 3.6952997651403627`*^9}, {3.6952999907739115`*^9, 3.6953002473314095`*^9}, {3.695300309672612*^9, 3.695300489271925*^9}, { 3.6953005232039742`*^9, 3.69530063425836*^9}, {3.695301974313356*^9, 3.6953019953283854`*^9}, {3.6953020979585876`*^9, 3.6953021778887005`*^9}, {3.6953022241387663`*^9, 3.695302456670373*^9}, { 3.695302502480466*^9, 3.6953026531831274`*^9}}] }, Open ]], Cell[TextData[{ "\ PART 3. ", StyleBox[" Discussion\ For Part 1 and Part 2, summarize the functionality \\ and math principles learned. Also describe how you tested the functionality \\ and determined correctness.\ This text must be formatted and for each Part, \\ the text should be at least 50 words.\ ", FontFamily->"Gill Sans MT"] }], "Subtitle", CellChangeTimes->{{3.6635267194027195`*^9, 3.663526728399234*^9}, { 3.663526775619934*^9, 3.6635267759329524`*^9}, {3.6635268320791636`*^9, 3.663526834549305*^9}, {3.6635270906159515`*^9, 3.663527098583407*^9}, { 3.6635309036730456`*^9, 3.663530905091127*^9}, {3.6635309821945367`*^9, 3.663531049960413*^9}, {3.663531102945443*^9, 3.663531155735463*^9}, { 3.6635311901764326`*^9, 3.6635311958357563`*^9}, {3.6635312385281982`*^9, 3.6635312832217546`*^9}, {3.6635313165806627`*^9, 3.6635313395879784`*^9}, {3.6635315809457836`*^9, 3.6635315868571215`*^9}, {3.6635317217898393`*^9, 3.6635317245769987`*^9}, {3.663532559838773*^9, 3.663532657432355*^9}, { 3.6635328235048532`*^9, 3.6635328273970766`*^9}, {3.6635329634348574`*^9, 3.663532988144271*^9}, {3.6635330187940235`*^9, 3.663533033747879*^9}, { 3.6635330694969234`*^9, 3.663533097340516*^9}, {3.663533131006442*^9, 3.663533382792843*^9}, {3.66353420621494*^9, 3.6635342480703344`*^9}, { 3.6952125135719233`*^9, 3.695212517071928*^9}, 3.695215568979404*^9, { 3.6952156050069857`*^9, 3.695215659574063*^9}, 3.6952157519205327`*^9, { 3.695216440603059*^9, 3.6952166026222982`*^9}, {3.695216633314842*^9, 3.6952167131924553`*^9}, {3.6952167656700296`*^9, 3.6952167905461774`*^9}, {3.6952983281020145`*^9, 3.6952983621674557`*^9}, {3.6952984157226467`*^9, 3.6952984414259615`*^9}, {3.695300686400548*^9, 3.6953007090115795`*^9}, { 3.6953007504811687`*^9, 3.695300864751399*^9}, {3.6953008976666317`*^9, 3.6953009711358333`*^9}}] }, WindowSize->{2266, 1293}, WindowMargins->{{24, Automatic}, {Automatic, 10}}, Magnification:>1.5 Inherited, FrontEndVersion->"11.0 for Mac OS X x86 (32-bit, 64-bit Kernel) (September \\ 21, 2016)", StyleDefinitions->"Default.nb" (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[558, 20, 665, 14, 284, "Subsection"], Cell[1226, 36, 572, 11, 235, "Subsection"], Cell[1801, 49, 178, 7, 185, "Subsection"], Cell[CellGroupData[{ Cell[2004, 60, 2119, 32, 477, "Subtitle"], Cell[4126, 94, 12703, 289, 1599, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[16866, 388, 1787, 26, 744, "Subtitle"], Cell[18656, 416, 14181, 320, 2002, "Input"] }, Open ]], Cell[32852, 739, 1910, 30, 678, "Subtitle"] } *) \f

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

College Algebra Graphs and Models

Authors: Marvin L. Bittinger, Judith A. Beecher, David J. Ellenbogen, Judith A. Penna

5th edition

321845404, 978-0321791009, 321791002, 978-0321783950, 321783956, 978-0321845405

More Books

Students also viewed these Mathematics questions

Question

Describe the four major levels of organisation policy.

Answered: 1 week ago