MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Polygons on spheres

  • To: mathgroup at smc.vnet.net
  • Subject: [mg54775] Re: [mg54710] Polygons on spheres
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Tue, 1 Mar 2005 01:58:35 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

>-----Original Message-----
>From: Steve Gray [mailto:stevebg at adelphia.net] 
To: mathgroup at smc.vnet.net
>Sent: Monday, February 28, 2005 9:27 AM
>To: mathgroup at smc.vnet.net
>Subject: [mg54775] [mg54710] Polygons on spheres
>
>	I have a need to draw and display "polygons" on 
>spheres. The edges of the polygons will all
>be arcs of great circles. Examples are triangles, etc., and 
>n-sided polygons which usually
>self-intersect. The great circle arcs must stop at the 
>vertices, which presumably can be done by
>correctly setting the range in the parametric plots of the 
>edges. Obviously several edges must be
>displayed at the same time, up to a dozen or two.
>	I want to see what these figures look like when the 
>vertices are moved around on the sphere,
>probably one at a time, constrained by certain rules.  I would 
>like to see the sphere as a colored
>surface with the lines standing out. I can specify the 
>vertices by theta-phi or whatever. My main
>concern is getting a good display, not the actual math. I will 
>need to vary the point of view to
>look at different parts of the sphere and maybe make an animation.
>	The part I'm uncertain about is getting a sphere and 
>the lines to show at the same time, and
>how to choose whether the lines on the back side of the sphere 
>are visible or not, so options should
>be transparent vs. translucent vs. opaque sphere.
>	Any suggestions will be welcome. Does anyone know if 
>Trott's book on Mathematica display coding
>covers this? If it will help, I'm willilng to buy it.
>
>Steve Gray
>
>

Steve,

this is a very hands-on exercise:

 
In[1]:= << Graphics`Shapes`
In[2]:=
gShere = Show[Graphics3D[{EdgeForm[GrayLevel[.5]], Sphere[2]}]]

A reasonable pretty sphere.

To define some points:

In[3]:=
x[r_, theta_, phi_] := r {Sin[theta] Cos[phi], Sin[theta]Sin[phi],
Cos[theta]}

In[4]:=
x1 = x[2.01, Pi/2, 0];
x2 = x[2.01, Pi/4, Pi/4];
x3 = x[2.01, 3/4Pi, Pi];
x4 = x[2.01, 3/5 Pi, Pi 3/8];
x5 = x[2.01, 7/8 Pi, Pi/8];


This gives the curved line segment graphics
(in honor of Prof. Peter Beckmann; this was my first exercise to his
lecture in mechanics):

In[9]:=
gL[x1_, x2_, style_:{}] := 
  Module[{p = Cross[x1, x2]/Sqrt[x1.x1]/Sqrt[x2.x2], l, e, phi2}, 
    l = Sqrt[p.p]; e = p/l;
    phi2 = If[Sign[x1.x2] < 0, Pi - ArcSin[l], ArcSin[l]]; 
    ParametricPlot3D[
      Append[Cross[e, #] Sin[ t] - Cross[e, Cross[e, #]] Cos[ t] &[x1], 
        style], {t, 0, phi2}, Compiled -> False, DisplayFunction ->
Identity]]



In[11]:= pnts = {x1, x2, x3, x4, x5}
In[12]:= segs = Partition[pnts, 2, 1, {1, 1}, {x1}]
In[13]:=
lines = MapIndexed[gL[First[#1], Last[#1], Hue[First[#2]/6]] &, segs]


Now display:

In[14]:=
Show[gShere, lines, Graphics3D[{PointSize[0.03],Hue[0],Point/@ pnts}],
  ViewPoint -> {4,6,2}]

In[15]:=
Show[%, ViewPoint -> {-3,5,-4}]


Of course this is not all you wanted, e.g. here two points on the sphere
are connected by the shortest arc, not always desired, perhaps. Also,
the arcs are drawn slightly above the sphere and not truly embedded.

Instead of a solid sphere you might use a wire skeleton to see the
segments from the backside.  Transparency needs a different rendering
engine, than that one Mathematica uses. Shure, it came be done!


--
Hartmut Wolf


  • Prev by Date: Mathematical Experiments
  • Next by Date: Re: Bug in Import?
  • Previous by thread: Re: Polygons on spheres
  • Next by thread: Re: Polygons on spheres