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

• To: mathgroup at smc.vnet.net
• Subject: [mg113364] Re: How to create a named compound 3D object?
• From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
• Date: Mon, 25 Oct 2010 06:41:42 -0400 (EDT)
• References: <ia10fk\$ot7\$1@smc.vnet.net>

```Graphics3D expects one set with graphics commands, so you simply need
to put { } around them.

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

This is true whether you use multiple simple graphics primitives or
complex combinations of them in lists. You can nest lists. They sort
of set up local environments; colors, point & line sizes defined in a
nested list do not effect higher levels.

Cheers -- Sjoerd

On Oct 24, 12:06 pm, Dims <dim... at hotmail.com> wrote:
> I wrote a code to draw a circle in 3D:
>
> Perp[v_] := If[v[] != 0 || v[] != 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: Re: Can one define own indexing function/mapping to be used for an Array
• Next by Date: Re: How to detect 'bad' characters in expressions in the notebook?
• Previous by thread: Re: How to create a named compound 3D object?
• Next by thread: Can one define own indexing function/mapping to be used for an Array