4
$\begingroup$

I cannot understand why the same transformations in 2D and 3D do not give the similar results (flat join segment line). In 3D the segments are not joined. Please help!

H = 0.5;
seg = {Line[{{0, 0}, {0, 2 H}}], Disk[{0, H}, 0.1]};
alpha[n_] := (1 + n /10) Pi/20;

Table[Translate[
 Rotate[seg, - 
 Sum[alpha[j], {j, 0, n}]], {H (Sin[ Sum[alpha[j], {j, 0, n}]] + 
   2 Sum[Sin[Sum[ alpha[j], {j, 0, i}]], {i, 1, n - 1}]), 
H (1 + Cos[ Sum[alpha[j], {j, 0, n}]] + 
   2 Sum[Cos[Sum[alpha[j], {j, 0, i}]], {i, 1, n - 1}])}], {n,30}];
Graphics[%]

enter image description here

H = 0.5;
seg = {Line[{{0, 0, 0}, {0, 0, 2 H}}], Sphere[{0, 0, H}, 0.1]};
alpha[n_] := (1 + n /10) Pi/20;

Table[Translate[
  Rotate[seg, 
Sum[ alpha[j], {j, 0, n}], {0, 1, 
 0}], {H (Sin[ Sum[alpha[j], {j, 0, n}]] + 
   2 Sum[Sin[Sum[ alpha[j], {j, 0, i}]], {i, 1, n - 1}]), 0, 
H (1 + Cos[ Sum[alpha[j], {j, 0, n}]] + 
   2 Sum[Cos[Sum[alpha[j], {j, 0, i}]], {i, 1, n - 1}])}], {n, 30}];
Graphics3D[%, Boxed -> False]

enter image description here

$\endgroup$
9
$\begingroup$

The first and fourth usage messages in the docs for Rotate[] read like so:

Rotate[g, θ]
represents 2D graphics primitives or any other objects g rotated counterclockwise by θ radians about the center of their bounding box.

...

Rotate[g, θ, w]
rotates 3D graphics primitives by θ radians around the 3D vector w anchored at the origin.

which is the reason for the discrepancy.

Thus, you need to specify the center of rotation explicitly (i.e., the second and fifth usages in the docs) and not count on the defaults if you'll be doing something this elaborate:

H = 0.5;
α[n_] := (1 + n/10) π/20;
σ[n_] := Sum[α[j], {j, 0, n}]


With[{seg = {Line[{{0, 0}, {0, 2 H}}], Disk[{0, H}, 0.1]}}, 
     Graphics[Table[
              Translate[Rotate[seg, -σ[n], {0, H}],
                        {H (Sin[σ[n]] + 2 Sum[Sin[σ[i]], {i, 1, n - 1}]),
                         H (1 + Cos[σ[n]] + 2 Sum[Cos[σ[i]], {i, 1, n - 1}])}],
                    {n, 30}]]]

2D

With[{seg = {Tube[{{0, 0, 0}, {0, 2 H, 0}}, 1./50], Sphere[{0, H, 0}, 0.1]}}, 
     Graphics3D[Table[
                Translate[Rotate[seg, -σ[n], {0, 0, 1}, {0, H, 0}],
                          {H (Sin[σ[n]] + 2 Sum[Sin[σ[i]], {i, 1, n - 1}]), 
                           H (1 + Cos[σ[n]] + 2 Sum[Cos[σ[i]], {i, 1, n - 1}]), 
                           0}],
                      {n, 30}],
                Boxed -> False, ViewPoint -> {0, 0, ∞}]]

3D

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.