Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

How to create a named compound 3D object?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113345] How to create a named compound 3D object?
  • From: Dims <dims12 at hotmail.com>
  • Date: Sun, 24 Oct 2010 06:06:49 -0400 (EDT)

I wrote a code to draw a circle in 3D:

Perp[v_] := If[v[[2]] != 0 || v[[3]] != 0,
  Cross[v, {1, 0, 0}],
  Cross[v, {0, 1, 0}]]

Circle3D[center_, dir_] :=
 Block[{perp1, perp2, pts, factor},
  perp1 = Normalize[Perp[dir]]*Norm[dir];
  perp2 = Normalize[Cross[dir, perp1]]*Norm[dir];
  factor = 0.6;
  pts = {
    center + perp1,
    center + perp1 + perp2*factor,
    center + perp1*factor + perp2,
    center + perp2,
    center - perp1*factor + perp2,
    center - perp1 + perp2*factor,
    center - perp1,
    center - perp1 - perp2*factor,
    center - perp1*factor - perp2,
    center - perp2,
    center - perp2 + perp1*factor,
    center - perp2*factor + perp1,
    center + perp1};
  (*{{BezierCurve[pts],Green,Line[pts],Red,Point[pts]}};*)
  BezierCurve[pts]
  ]

Then I create a compound object (which looks like a line,
circuferenced with serie of circles):

Rails[p1_, p2_, t_] := Block[{totlen, dirvect, preans},
   totlen = Norm[p2 - p1];
   dirvect = Normalize[p2 - p1];
   preans = {Line[{p2, p1}]};
   For[p = p1, Norm[p - p1] < totlen, p += dirvect*t,
    preans = Append[preans, Circle3D[p, dirvect]]];
   preans];

But unfortunately, I was to prepare an anwer as a List. But this is
not very suitable to use in Graphics, because I need to use Join to
draw:

Graphics3D[
 Join[Rails[{0, 0, 0}, {10, 0, 0}, 1],
  Rails[{0, 0, 0}, {0, 10, 0}, 1]]]

Is it possible to define compound object so that it can be used like
normal ones:

Graphics3D[
Rails[{0, 0, 0}, {10, 0, 0}, 1],
  Rails[{0, 0, 0}, {0, 10, 0}, 1]]

?

Thanks.


  • Prev by Date: fyi, A nice package for making plot ticks
  • Next by Date: Re: Variable number of arguments
  • Previous by thread: Re: fyi, A nice package for making plot ticks
  • Next by thread: Re: How to create a named compound 3D object?