       Re: Visualising a spherical triangle

• To: mathgroup at smc.vnet.net
• Subject: [mg85431] Re: Visualising a spherical triangle
• From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
• Date: Sun, 10 Feb 2008 05:18:19 -0500 (EST)
• References: <fojr91\$gk2\$1@smc.vnet.net>

```Hi,

what is with

SubDivide[Polygon[tri : {{_, _} ..}]] :=
Module[{center},
center = Mean /@ Transpose[{tri, RotateLeft[tri]}];
Polygon /@
Append[Transpose[{RotateRight[center], tri, center}], center]
]
SubDivide[lst : {__Polygon}] := Flatten[SubDivide /@ lst]

SubDivide[lst_, n_Integer] := Nest[SubDivide, lst, n]

ToSphere[{th_?NumericQ, phi_?NumericQ}] :=
{Cos[phi]*Sin[th], Sin[phi]*Sin[th], Cos[th]}
ToSphere[Polygon[pnts_]] := Polygon[ToSphere /@ pnts]
ToSphere[lst : {__Polygon}] := ToSphere /@ lst

and

With[{nSubdivde = 4},
Graphics3D[
{Sphere[{0, 0, 0}, 1],
ToSphere[
SubDivide[Polygon[{{Pi/3, 0}, {2 Pi/3, 0}, {Pi/3, Pi/3}}],
nSubdivde] ] /.
Polygon[pnts_] :> Line[Append[pnts, First[pnts]]]}
]
]

should give you a triangle on the sphere ...
and

With[{nSubdivde = 4},
Graphics3D[
{Sphere[{0, 0, 0}, 1],
ToSphere[
SubDivide[Polygon[{{Pi/3, 0}, {2 Pi/3, 0}, {Pi/3, Pi/3}}],
nSubdivde] ,1.1] /.
Polygon[pnts_] :> {Hue[Random[]], Polygon[pnts]}}
]
]

will color the individual polygons

and

With[{nSubdivde = 4},
Graphics3D[
{Sphere[{0, 0, 0}, 0.975], EdgeForm[], RGBColor[1, 0, 0, 0.5],
ToSphere[
SubDivide[Polygon[{{Pi/3, 0}, {2 Pi/3, 0}, {Pi/3, Pi/3}}],
nSubdivde] , 1]}
]
]

will draw a transparent red triangle on the sphere.
Be careful when setting the radius of the sphere a bit smaller
than the radius of the triangle, otherwise some parts
of the triangle mesh may be hidden ..

Regards
Jens

Alexander Erlich wrote:
> Hello,
>
> I would like to visualize the a spherical triangle between Bremen (Germany),
> Chicago and Shanghai on the world sphere. Although there are some notebooks
> on the Documentation Project which deal with spherical triangles, I had
> trouble understanding them (being rather new to mathematica), and I could
> not find a way to modify any of them to my purpose.
>
> Could you tell me how to visualize a spherical triangle? Or (if this is
> easier) how to modify an existing notebook to visualize it?
>
> Regards,
> Alexander
>
>

```

• Prev by Date: Re: button to load files from a window