How to draw a great circle on a sphere? - Mathematica Stack Exchange most recent 30 from mathematica.stackexchange.com 2019-09-22T04:59:28Z https://mathematica.stackexchange.com/feeds/question/16413 https://creativecommons.org/licenses/by-sa/4.0/rdf https://mathematica.stackexchange.com/q/16413 19 How to draw a great circle on a sphere? Tesseract https://mathematica.stackexchange.com/users/5042 2012-12-16T11:51:29Z 2018-02-14T23:36:20Z <p>I apologize for the text description, but new users are not allowed to post images. </p> <p>I want to draw a circle that cuts through the center of a sphere and has an inclination of 15 degrees with the horizontal axes (equator). Actually, there are infinite number of great circles that can satisfy this requirement. If someone can show me how to make a <code>Manipulation</code>, that will be better.</p> https://mathematica.stackexchange.com/questions/16413/-/16415#16415 22 Answer by ssch for How to draw a great circle on a sphere? ssch https://mathematica.stackexchange.com/users/1517 2012-12-16T13:19:20Z 2013-04-11T10:52:34Z <p>The idea is quite simple: Since any great circle can be parametrized as $\cos(\theta)u + \sin(\theta)v$ where $u$ and $v$ are two orthonormal vectors. One can start with $u=\{1,0,0\}, v=\{0,1,0\}$ and use <code>RotationTransform</code> to get out of the xy plane, then use <code>RotationTransform</code> again to spin around the z-axis to get all great circles with desired inclination.</p> <pre><code>Manipulate[ (* Rotation deg° out of the xy plane *) rx = RotationTransform[deg Degree, {0, 1, 0}]; (* Spin around z axis *) rz = RotationTransform[ϕ Degree, {0, 0, 1}]; {u, v} = rz @ rx @ {{1, 0, 0}, {0, 1, 0}}; Show[{ Graphics3D[{ {Opacity[0.4], Sphere[]}, {Opacity[0.5], Polygon[{ {-1, -1, 0}, {1, -1, 0}, {1, 1, 0}, {-1, 1, 0}}]}, {Arrow[{{0, 0, 0}, u}], Arrow[{{0, 0, 0}, v}]} }], ParametricPlot3D[{ Cos[θ] u + Sin[θ] v, (* The great circle in question *) {Cos[θ], Sin[θ], 0}, (* Normal unit circle *) RotationTransform[θ, {0, 0, 1}] /@ {u, -u} (* The red dashed stuff *) }, {θ, -Pi, Pi}, PlotStyle -&gt; {Directive[Blue, Thick], Black, Directive[Red, Dashed]}] }, Axes -&gt; True, AxesLabel -&gt; {"x", "y", "z"}], {{deg, 15, "Inclination"}, -180, 180}, {ϕ, 0, 360}] </code></pre> <p><img src="https://i.stack.imgur.com/TsyZz.png" alt="Output"></p> https://mathematica.stackexchange.com/questions/16413/-/16417#16417 16 Answer by m_goldberg for How to draw a great circle on a sphere? m_goldberg https://mathematica.stackexchange.com/users/3066 2012-12-16T13:51:11Z 2012-12-17T08:06:56Z <p>Here is a static solution to the problem. It shows a mesh on the sphere that represents the normal lat-long coordinate system.</p> <p>A function representing the equator.</p> <pre><code>equator[θ_] := {Cos[θ], Sin[θ], 0} </code></pre> <p>A function and a plot representing the inclined circle. Note that the inclination is accomplished by a rotation of the equator about the <em>x</em>-axis.</p> <pre><code>inclinedCircle[θ_, i_] := RotationTransform[i, {1, 0, 0}][equator[θ]]; circlePlot[i_] := ParametricPlot3D[ Evaluate[inclinedCircle[θ, i °]], {θ, 0, 2 π}, PlotStyle -&gt; {Thickness[0.005]}] </code></pre> <p>A function and a plot representing the sphere. </p> <pre><code>sphere[u_, v_] := {Cos[u] Cos[v], Sin[u] Cos[v], Sin[v]}; spherePlot = ParametricPlot3D[ Evaluate[sphere[u, v]], {u, 0, 2 π}, {v, -π, π}]; </code></pre> <p>A great circle inclined at 60°.</p> <pre><code>Show[{spherePlot, circlePlot}, Axes -&gt; False, Boxed -&gt; False, PlotRange -&gt; All, SphericalRegion -&gt; True, ViewPoint -&gt; {5, 0, 0}, ViewAngle -&gt; 12 °] </code></pre> <p><img src="https://i.stack.imgur.com/YQJXq.png" alt="enter image description here"></p> <h3>Update 1</h3> <p>With a little modification to <code>inclinedCircle</code> and <code>circlePlot</code> to handle nodal point shift, it is easy to construct an interactive version. A rotation about the <em>z</em>-axis has been added to accomplish the nodal shift.</p> <pre><code>inclinedCircle[θ_, i_, offset_] := RotationTransform[offset, {0, 0, 1}] [RotationTransform[i, {1, 0, 0}][equator[θ]]]; circlePlot[i_, offset_: 0] := ParametricPlot3D[ Evaluate[inclinedCircle[θ, i °, offset °]], {θ, 0, 2 π}, PlotStyle -&gt; {Thickness[0.005]}] </code></pre> <p>The parameter ι is the inclination and the parameter α is the equatorial ascending node.</p> <pre><code>Manipulate[ Show[{spherePlot, circlePlot[ι, α]}, Axes -&gt; False, Boxed -&gt; False, PlotRange -&gt; All, SphericalRegion -&gt; True, ViewPoint -&gt; {5, 0, 0}, ViewAngle -&gt; 12 °], {{ι, 60.}, 0., 90., 5., Appearance -&gt; "Labeled"}, {{α, 0.}, 0., 355., 5., Appearance -&gt; "Labeled"}, SaveDefinitions -&gt; True] </code></pre> <p><img src="https://i.stack.imgur.com/kMUUc.png" alt="enter image description here"></p> <h3>Update 2</h3> <p>Rather than describing a great circle as the composition of rotations applied to the equator, those rotations can be used to derive a more conventional description, a parametic function built from elementary trigonometric functions. To do this, first apply <code>inclinedCircle</code> to some value-free symbols.</p> <pre><code>Clear[θ, ι, φ]; inclinedCircle[θ, ι, φ] </code></pre> <blockquote> <p>{Cos[θ] Cos[φ] - Cos[ι] Sin[θ] Sin[φ], Cos[ι] Cos[φ] Sin[θ] + Cos[θ] Sin[φ], Sin[θ] Sin[ι]}</p> </blockquote> <p>From the output expression, write a function generator, <code>inclinedCircle</code>, that when given the inclination ι and the ascending node φ, returns a pure function producing the points on the desired great circle. </p> <pre><code>inclinedCircleF[ι_, φ_] = {Cos[#] Cos[φ] - Cos[ι] Sin[#] Sin[φ], Cos[ι] Cos[φ] Sin[#] + Cos[#] Sin[φ], Sin[#] Sin[ι]}&amp;; </code></pre> <p>Next write a plotting function that will use the function generator rather than the rotations.</p> <pre><code>circlePlot2[ι_, φ_: 0.] := ParametricPlot3D[ inclinedCircleF[ι °, φ °][θ], {θ, 0., 2. π}, PlotStyle -&gt; {Thickness[0.005]}] </code></pre> <p>Finally, substitute the new plotting function for the original one in the <code>Manipulate</code>.</p> <pre><code>Manipulate[ Show[{spherePlot, circlePlot2[ι, φ]}, Axes -&gt; False, Boxed -&gt; False, PlotRange -&gt; All, SphericalRegion -&gt; True, ViewPoint -&gt; {5, 0, 0}, ViewAngle -&gt; 12 °], {{ι, 60.}, 0., 90., 5., Appearance -&gt; "Labeled"}, {{φ, 0.}, 0., 355., 5., Appearance -&gt; "Labeled"}, SaveDefinitions -&gt; True] </code></pre> <p>The output from evaluating this <code>Manipulate</code> expression is exactly the same as with the one using rotations, so I won't repeat it here.</p> https://mathematica.stackexchange.com/questions/16413/-/16434#16434 13 Answer by whuber for How to draw a great circle on a sphere? whuber https://mathematica.stackexchange.com/users/91 2012-12-16T19:12:14Z 2013-04-11T10:58:21Z <p>Great answers have already appeared. In the spirit of demonstrating multiple solutions to a problem with <em>Mathematica</em>, I would like to offer one using a different approach.</p> <p><strong>First, some geometric analysis.</strong> This great circle bounds a hemisphere lying in a half-space determined by a normal direction to the circle's plane. Letting $\theta$ be the latitude at which the circle crosses the equator, we find that $(\cos(\theta), \sin(\theta), 0)$ is a direction on the circle. The perpendicular direction $(-\sin(\theta), \cos(\theta), 0)$ has to be elevated by an angle $\alpha$, whence it equals $(-\cos(\alpha) \sin(\theta), \cos(\alpha)\cos(\theta), \sin(\alpha))$. The cross-product of these vectors is the desired normal direction.</p> <p><strong>One expedient--and straightforward--solution uses <code>Contour3D</code></strong> to depict the surface of the sphere as the contour $x^2+y^2+z^2=1$ and exploits its <code>RegionFunction</code> option to limit that contour to the desired hemisphere.</p> <p><strong>For reference</strong> I use a world globe taken directly from the help page for <code>Texture</code>. It requires an image of the world's surface, such as</p> <pre><code>im = Import["http://www.ngdc.noaa.gov/mgg/topo/pictures/GLOBALeb6colshadesmall.jpg"]; </code></pre> <p>This is plastered onto a slightly shrunken parametric plot of a sphere (or ellipsoid, if you want greater realism), stripped of all detail except this texture:</p> <pre><code>globe = ParametricPlot3D[0.99 {Cos[u] Sin[v], Sin[u] Sin[v], Cos[v]}, {u, 0, 2 π}, {v, 0, π}, Mesh -&gt; None, TextureCoordinateFunction -&gt; ({#4, 1 - #5} &amp;), PlotStyle -&gt; Directive[Specularity[White, 20], Texture[im]], Lighting -&gt; "Neutral", Axes -&gt; False, RotationAction -&gt; "Clip"]; </code></pre> <p>Over that we may drape the hemisphere semi-transparently.</p> <p><img src="https://i.stack.imgur.com/0gSQJ.png" alt="Image"></p> <p>The code allows dynamic manipulation of the elevation and orientation ("azimuth") of the great circle.</p> <pre><code>Manipulate[ Block[{normal = Cross[{Cos[θ], Sin[θ], 0}, {Cos[α] (-Sin[θ]), Cos[α] Cos[θ], Sin[α]}]}, Show[globe, ContourPlot3D[x^2 + y^2 + z^2, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, Contours -&gt; {1}, ContourStyle -&gt; Opacity[0.5], Mesh -&gt; None, RegionFunction -&gt; Function[{x, y, z}, normal . {x, y, z} ≥ 0]], Boxed -&gt; False]], {{α, 0, "Elevation"}, -π/2, π/2}, {{θ, 0, "Azimuth"}, -π, π} ] </code></pre> <p>Include additional 3D graphics as you will to indicate the normal direction, the Equatorial Plane, a latitude-longitude graticule, etc.</p> https://mathematica.stackexchange.com/questions/16413/-/19350#19350 13 Answer by user5844 for How to draw a great circle on a sphere? user5844 https://mathematica.stackexchange.com/users/0 2013-02-09T11:31:23Z 2013-02-09T11:31:23Z <p>As noted in <a href="https://mathematica.stackexchange.com/q/10957">this thread</a>, it's often more convenient to manipulate B-splines instead of lines.</p> <p>Thus, using the B-spline representation derived by Piegl and Tiller in <a href="http://dx.doi.org/10.1109/38.35537" rel="nofollow noreferrer">this article</a>, we have the following routine:</p> <pre><code>greatCircle[φ_, θ_, r_: 1] := BSplineCurve[ Composition[RotationTransform[θ, {0, 0, 1}], RotationTransform[-φ, {0, 1, 0}]] /@ (r {{1, 0, 0}, {1, 1, 0}, {-1, 1, 0}, {-1, 0, 0}, {-1, -1, 0}, {1, -1, 0}, {1, 0, 0}}), SplineDegree -&gt; 2, SplineKnots -&gt; {0, 0, 0, 1/4, 1/2, 1/2, 3/4, 1, 1, 1}, SplineWeights -&gt; {1, 1/2, 1/2, 1, 1/2, 1/2, 1}] </code></pre> <p>Try it out:</p> <pre><code>With[{ε = 1*^-3 (* shrinks sphere slightly *), φ = 30° (* inclination *)}, Graphics3D[{{Opacity[2/5, Blue], Sphere[{0, 0, 0}, 1 - ε]}, {Directive[AbsoluteThickness, Red], greatCircle[φ, 0]}}, Lighting -&gt; "Neutral"]] </code></pre> <p><img src="https://i.stack.imgur.com/2SUJH.png" alt="sphere and great circle"></p> <p>Spin things around a bit:</p> <pre><code>With[{ε = 10^-3, φ = 30°}, Animate[Graphics3D[{{Opacity[2/5, Blue], Sphere[{0, 0, 0}, 1 - ε]}, {Directive[AbsoluteThickness, Red], greatCircle[φ, θ]}}, Lighting -&gt; "Neutral", SphericalRegion -&gt; True], {θ, 0, 360°, 15°}]] </code></pre> <p><img src="https://i.stack.imgur.com/VxRry.gif" alt="rotating sphere and great circle"></p> <p>Adding the fancy stuff (e.g. arrows and planes) is left to you as an exercise.</p> https://mathematica.stackexchange.com/questions/16413/-/63183#63183 10 Answer by luyuwuli for How to draw a great circle on a sphere? luyuwuli https://mathematica.stackexchange.com/users/6468 2014-10-15T08:09:35Z 2014-10-15T08:09:35Z <p>Just use <code>MeshFunction</code>.</p> <pre><code>Manipulate[ParametricPlot3D[{Sin[\[Theta]] Cos[\[Phi]], Sin[\[Theta]] Sin[\[Phi]], Cos[\[Theta]]}, {\[Theta], 0, \[Pi]}, {\[Phi], 0, 2 \[Pi]}, PlotStyle -&gt; Opacity[0.5], Mesh -&gt; {{0.}}, MeshStyle -&gt; {Red, Thick}, MeshFunctions -&gt; {Sin[a] Cos[b] #1 + Sin[a] Sin[b] #2 + Cos[a] #3 &amp;}], {a, 0, \[Pi]}, {b, 0, 2 \[Pi]}] </code></pre> <p><img src="https://i.stack.imgur.com/nlRXu.jpg" alt="enter image description here"></p> <p>Let me explain my code.</p> <p>Since the great circle is the intersection of the sphere and a plane passing through the origin. So all you have to do is to</p> <ol> <li>Find or define the normal vector of the plane. In my case, $(\sin{a}\cos{b},\sin{a}\sin{b},\cos{a})$</li> <li>Translate the mathematical plane equation into <code>MeshFunction</code>, i.e. <code>Sin[a]Cos[b]#1+Sin[a]Sin[b]#2+Cos[a]#3 &amp;</code></li> </ol> <p><em>Mathematica</em> will do the rest. Enjoy:)</p>