Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Graphics3D question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110116] Re: Graphics3D question
  • From: "David Park" <djmpark at comcast.net>
  • Date: Wed, 2 Jun 2010 02:06:25 -0400 (EDT)

As Wolfgang Pauli would say: "It's not even wrong!"

Nevertheless, in this case, I can make up an example that illustrates the
labeling of a collection of spheres at random positions so that the labels
are true 3D labels that show perspective and hide behind foreground
surfaces. It uses the Text3D capability in the Presentations package.

Peter Lindsay at the School of Mathematics and Statistics at the University
of St Andrews [ http://www.mcs.st-and.ac.uk/ ] helps me keep an archive of
Presentation solutions to MathGroup questions. These are available in both
notebook and PDF form at:

http://blackbook.mcs.st-and.ac.uk/~Peter/djmpark/html/ 

This should appear there within a day or two.


Needs["Presentations`Master`"]

The following is a routine for drawing a labeled sphere.
1) For this example the spheres are all the same size, radius 2.
2) We label the spheres using a VerticalVectorText3D label, in a vertical
plane, and then project it onto the sphere using DrawingTransform3D combined
with the Mathematica Normalize command.
3) We used vector fonts so they will bend smoothly onto the sphere, but it
is also necessary to fine grain the longer lines.
4) The sphere are labeled on both sides so we will have a better chance of
seeing a label from various angles. (But we can't see the labels from all
angles.)
5) The position of the label on the sphere can be varied, around the
equator, with the angle parameter. This is effected using RotateOp.
6) The sphere is then translated to the final position.

LabeledSphere[position_, label_String, angle_, color_] :=
 Module[{normalized = Function /@ (2 Normalize[{#1, #2, #3}])},
  {{color, Sphere[{0, 0, 0}, 2],
     Black, AbsoluteThickness[1],
     {(Normal@
           VerticalVectorText3D[label, {2, 0, 0}, \[Pi]/2, {1, 1}] // 
          FineGrainLines[0.05, 4]) /. DrawingTransform3D @@ normalized,
       (Normal@
           VerticalVectorText3D[label, -{2, 0, 0}, -\[Pi]/2, {1, 1}] //
           FineGrainLines[0.05, 4]) /. 
        DrawingTransform3D @@ normalized} // 
      RotateOp[angle, {0, 0, 1}]} // TranslateOp[position]
   }] 

The spheres are colored using one of the Indexed color sets from the Color
Schemes palette. 

ColorData[27] 

The following generates 10 random sphere positions in the box of side 20
centered at the origin. 

positions = RandomReal[{-10, 10}, {10, 3}]; 

The following then draws the spheres. The sphere labels are right on the
spheres, show the same perspective as the spheres, and are covered by
foreground spheres. 

Draw3DItems[
 {Table[LabeledSphere[positions[[i]], ToString[i], -\[Pi]/4, 
    ColorData[27, i]], {i, 10}]},
 NeutralLighting[0, .5, .1],
 NiceRotation,
 PlotRange -> 12,
 PlotRegion -> {{.1, .9}, {.1, .9}},
 ViewPoint -> {1, -1, .2} 1.2,
 Boxed -> False,
 ImageSize -> 350] 

One feature of Text3D labeling is that the labeling is fixed to the object
and when you rotate the object with the mouse the labels rotate also and may
become partially or totally hidden from view. But then, if there is a sign
in front of a building and you walk around the building, the sign doesn't
walk with you. 

The following is the same set of spheres with the labeling put on at random
angles. 

Draw3DItems[
 {Table[LabeledSphere[positions[[i]], ToString[i], 
    RandomReal[{0, -\[Pi]/2}], ColorData[27, i]], {i, 10}]},
 NeutralLighting[0, .5, .1],
 NiceRotation,
 PlotRange -> 12,
 PlotRegion -> {{.1, .9}, {.1, .9}},
 ViewPoint -> {1, -1, .2} 1.2,
 Boxed -> False,
 ImageSize -> 350] 


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  


From: S. B. Gray [mailto:stevebg at ROADRUNNER.COM] 

I have some spheres in a 3D display. Each sphere has a number.

Graphics3D[{{RGBColor[0.4, 1.0, 0.9, .2],
    		 EdgeForm[Gray],
    Table[Cylinder[{circls[[dx, 1]],
       circls[[dx, 1]] + .01*circls[[dx, 3]]}, circls[[dx, 2]]],
       {dx, 1, Length[circls]}]},
   	PointSize[0.015], Red,  Point[taba1],		
   	PointSize[0.015], Blue, Point[taba2],
   	Thickness[.003], White, Line[lines],
                          LightBlue, Sphere[coords, .6],
   	Yellow,
   Table[Style[Text[xr, coords[[xr]]], FontSize -> imsize/30,
     FontFamily -> "Arial Bold"],
    					     {xr, 1, numbr}]},
  Boxed -> False, ImageSize -> 800]

I notice two things that could be better:

1. The numbers do not get smaller on the more distant spheres. It would 
be better if they had perspective like the spheres themselves do.

2. When one sphere is occluded by another, its number is not occluded 
but appears in front of the front sphere along with the front number.

Is there a way to make the numbers behave like other image elements do?

Steve Gray




  • Prev by Date: Re: Deleting Duplicates
  • Next by Date: Export
  • Previous by thread: Re: Graphics3D question
  • Next by thread: Re: Problems running Mathematica and WordMS together in