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

MathGroup Archive 2010

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

Search the Archive

Re: How to create a named compound 3D object?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113348] Re: How to create a named compound 3D object?
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Mon, 25 Oct 2010 06:38:40 -0400 (EDT)

Use this

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


Bob Hanlon

---- Dims <dims12 at hotmail.com> wrote: 

=============
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: discrete points in 3D polar
  • Next by Date: Re: Can one define own indexing function/mapping to be used for an Array
  • Previous by thread: How to create a named compound 3D object?
  • Next by thread: Re: How to create a named compound 3D object?