Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Picking out pieces of a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg75910] Picking out pieces of a list
  • From: Hatto von Aquitanien <abbot at AugiaDives.hre>
  • Date: Sun, 13 May 2007 05:45:51 -0400 (EDT)

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?

-- 
http://www.dailymotion.com/video/x1ek5w_wtc7-the-smoking-gun-of-911-updated
http://911research.wtc7.net
http://vehme.blogspot.com
Virtus Tutissima Cassis


  • Prev by Date: Re: elliptic integral (reloaded!)
  • Next by Date: Re: Re: question 1
  • Previous by thread: Three unrelated questions about Graphics and Mathematica 5.2
  • Next by thread: Re: Picking out pieces of a list