Tag Info

New answers tagged

8

I think you can regard each one of your edges/vertices as a complex number, so walk along the path given an angle set will be equivalent to adding the corresponding number set successively. And if the total is $0$, it means the path is closed, thus a polytan. This is a possible implementation: Clear[polytanPlot] polytanPlot[angleSet_] := ...


2

Your own formula can be refactored in a more concise form: f1 = With[{c = +##/2}, c + (# - c).{{0, -1}, {1, 0}} & /@ {##}] &; +##/2 is a "trick" that here is equivalent to Mean[{#, #2}] the function needs to be applied with @@@ rather than /@ A shorter function can be written using Cross, similar to what J. M. used: f2 = {+##, # - #2}/2 ...


2

Had Rotate[]/RotationTransform[] not been available, here's a possible alternative: BlockRandom[SeedRandom[123, Method -> "MKL"]; (* for reproducibility *) segs = Arrow[RandomVariate[NormalDistribution[], {5, 2, 2}]]]; Graphics[{{Blue, segs}, {Red, segs /. s_?MatrixQ :> With[{m = Mean[s]}, m + Cross[# - m] & /@ s]}}]


5

data = RandomReal[1, {5, 2}] Whole rotation Graphics[{Line[data], {Red, Rotate[Line[data], Pi/2]}}] Single segment rotation Graphics[{Line[data], {Red, Rotate[Line[#], Pi/2]} & /@ Partition[data, 2, 1]}]


9

Something along the lines of Rotate[Line[pts], angle, Mean[pts]]: g = Graphics[Line[{{1, 1}, {2, 2}}]]; rot = l : Line[pts_] :> Rotate[l, Pi/2, Mean[pts]]; Show[g, g /. rot] I believe that Rotate and family are Graphics/Graphics3D directives which are only processed when they are rendered. If you need to access actual rotated values of the points, ...



Top 50 recent answers are included