Re: Picking out pieces of a list
- To: mathgroup at smc.vnet.net
- Subject: [mg75973] Re: Picking out pieces of a list
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Mon, 14 May 2007 03:41:57 -0400 (EDT)
- References: <f26nc2$42l$1@smc.vnet.net>
Hi, and Graphics3D[{Opacity[.3], EdgeForm[], {Line[#], Polygon[#]} &@pts[[All, 1]], Polygon[#] &@pts[[All, 2]], Polygon[Flatten[{#[[1]], Reverse[#[[2]]]}, 1] ] & /@ Partition[pts, 2, 1]}] does not help ? Regards Jens Hatto von Aquitanien wrote: > Here's the motivation. I want to draw slice out of a cone. (I don't know > the proper mathematical term for this, but my meaning should be clear from > the code.) Note: See Feynman, Vol II, Page 1-8. > > (*A function that generates coordinates:*) > > R3[\[Theta]_, r_: 1.0, p_: {0, 0, 0}] := > r {0, Cos@\[Theta], Sin@\[Theta]} + p > > (*Some "constant" values:*) > > r1 = 1.0; > r2 = 0.8; > \[CapitalDelta]x = 0.5; > > (*Points representing the centers of the circular faces:*) > > p1 = {\[CapitalDelta]x, 0, 0}; > p2 = {0, 0, 0}; > > (*A list of point pairs:*) > > pts = {R3[#, r1, p1], R3[#, r2, p2]} & /@Range[-\[Pi], \[Pi], \[Pi]/20]; > > (*Draw the circular faces, and the reference curve:*) > > Graphics3D[{ > Opacity[.3] > , EdgeForm[] > , {Line[#], Polygon[#]} &@pts[[All, 1]] > , Polygon[#] &@pts[[All, 2]] > }] > > Now, I know I can use table, or some kind of brute force manipulation with > (...)&/Range[Length@pts] to extract the points in the correct order to draw > the polygons for the sides. What I want to know is whether there is a way > to use Part[] to get the four points in one statement. > > Here's a little scratch-pad code I created to explore the problem. > > c = CharacterRange["1", "9"] > (lst = Table[ > DisplayForm[ > SubscriptBox["P", c[[i]] <> c[[j]] <> c[[k]]]] > , {i, 1, Length@c} > , {j, 1, 2} > , {k, 1, 2}]) // MatrixForm > > (*Get the points of the first ring*) > > lst[[All, 1]] // MatrixForm > > (*Get the points of the second ring*) > > lst[[All, 2]] // MatrixForm > > (*Here is /a/ solution to the problem:*) > > m[n_, lst_] := lst[[Mod[n + 1, Length@lst, 1]]] > > Join[lst[[#]][[{1, 2}]], m[#, lst][[{2, 1}]]] & /@ Range@len // MatrixForm > > Is there a "tighter" way to accomplish the same thing? >