RE: Illumination or obfuscation?

*To*: mathgroup at smc.vnet.net*Subject*: [mg43986] RE: [mg43943] Illumination or obfuscation?*From*: "David Park" <djmp at earthlink.net>*Date*: Thu, 16 Oct 2003 04:16:45 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

Steven, It is not meant to illuminate but to be compact and efficient. The trouble with one-liners is that they are difficult to follow. But all you have to do is unravel them. Needs["Graphics`Arrow`"] Needs["Graphics`Colors`"] px = {1, 0}; py = {0, 1}; m[th_] := {{Cos[th], Sin[th]}, {-Sin[th], Cos[th]}} We can experiment and see what the routine does. It clearly draws two arrows. crossPoint[{1, 1}] {Arrow[{0.5, 1.}, {1.5, 1.}, HeadLength -> 0.015], Arrow[{1., 0.5}, {1., 1.5}, HeadLength -> 0.015]} Play around with the parameters in the following plot to see what it does Show[Graphics[ {crossPoint[pt = {1, 3}, 45°, 6], Red, AbsolutePointSize[5], Point[pt]}], AspectRatio -> Automatic, PlotRange -> All, Frame -> True]; Now we can unravel it... p = {1, 3}; th = \[Pi]/4; L = 6; Print["Initial vectors"] {px, py} Print["Stretching them"] L%% Print["Forming two symmetrical points for Arrow"] {-#, #} & /@ %% Print["Rotating and shifting the coordinates"] p + #.m[th] & /@ %% Print["Inserting each row into the Arrow command"] Arrow[##, HeadLength -> 0.015] & @@ # & /@ %% Only the last instruction is a little difficult. It is inserting two arguments into the Arrow primitive by apply the function to each row of the preceding matrix. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Steven T. Hatton [mailto:hattons at globalsymmetry.com] To: mathgroup at smc.vnet.net To an experienced Mathematica user, is the following snippet clear, and easy to understand, or simply an exercise in obfuscation? Assume I already have px,py and m[] lying around. px = {1, 0}; py = {0, 1}; m[th_] := {{Cos[th], Sin[th]}, {-Sin[th], Cos[th]}} crossPoint[p_, th_:0, L_:0.5] := Arrow[##,HeadLength -> 0.015]&@@#&/@(p+#.m[th]&/@{-#, #}&/@(L{px, py}))