Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. MotiPoin[A_, B_, C0_, r0_, theta0_, b_, alpha_] :=
  2. Module[{q0, trif, K2, T, h, eq},
  3. q0 = (C0 r0 Tan[theta0])/B;
  4. trif = (2 \[Pi] B)/(r0 (A Cos[theta0] + C0 Sin[theta0] Tan[theta0]));
  5. K2 = (B q0)^2 + (C0 r0)^2;
  6. T = 1/2 (B q0^2 + C0 r0^2);
  7. h = Sqrt[(2 T)/K2];
  8. eq1 = Derivative[1][p][t] == ((B - C0) q[t] r[t])/A;
  9. eq2 = Derivative[1][q][t] == ((C0 - A) p[t] r[t])/B;
  10. eq3 = Derivative[1][r][t] == ((A - B) p[t] q[t])/C0;
  11. eq4 = Derivative[1][psi][
  12. t] == (Cos[phi[t]] q[t] + p[t] Sin[phi[t]])/Sin[theta[t]];
  13. eq5 = Derivative[1][phi][t] ==
  14. r[t] - Cot[theta[t]] (Cos[phi[t]] q[t] + p[t] Sin[phi[t]]);
  15. eq6 = Derivative[1][theta][t] == p[t] Cos[phi[t]] - q[t] Sin[phi[t]];
  16. w1 = (Cos[phi[t]] Cos[psi[t]] -
  17. Sin[phi[t]] Sin[psi[t]] Cos[theta[t]]) p[
  18. t] - (Cos[psi[t]] Sin[phi[t]] +
  19. Cos[phi[t]] Cos[theta[t]] Sin[psi[t]]) q[t] +
  20. r[t] Sin[psi[t]] Sin[theta[t]];
  21. w2 = (Cos[psi[t]] Cos[theta[t]] Sin[phi[t]] +
  22. Cos[phi[t]] Sin[psi[t]]) p[
  23. t] + (Cos[phi[t]] Cos[psi[t]] Cos[theta[t]] -
  24. Sin[phi[t]] Sin[psi[t]]) q[t] - Cos[psi[t]] r[t] Sin[theta[t]];
  25. w3 = Cos[theta[t]] r[t] + Cos[phi[t]] q[t] Sin[theta[t]] +
  26. p[t] Sin[phi[t]] Sin[theta[t]];
  27. sol = NDSolve[{eq1, eq2, eq3, eq4, eq5, eq6, p[0] == 0, q[0] == q0,
  28. r[0] == r0, psi[0] == 0, phi[0] == 0, theta[0] == theta0}, {p, q,
  29. r, psi, phi, theta}, {t, 0, b trif}];
  30. {x, y} = Flatten[{-((w1 h)/w3), -((w2 h)/w3)} /. sol];
  31. z = x^2 + y^2;
  32. If[A < C0 < B || B < C0 < A, Goto[2], Goto[1]];
  33. Label[1];
  34. m = FindMinimum[z, {t, 0, 0, b trif}];
  35. M = FindMinimum[-z, {t, 0, 0, b trif}];
  36. ra1 = Sqrt[m[[1]]];
  37. ra2 = Sqrt[-M[[1]]];
  38. Print["L'erpoloide è contenuta in una corona circolare"];
  39. Print["avente raggio interno ra1 e raggio esterno ra2"];
  40. Print["ra1=", ra1]; Print["ra2=", ra2];
  41. c1 = ParametricPlot[{ra1 Sin[u], ra1 Cos[u]}, {u, 0, 2 \[Pi]},
  42. AspectRatio -> 1, PlotStyle -> RGBColor[0.8669, 0.258, 0.227]];
  43. c2 = ParametricPlot[{ra2 Sin[u], ra2 Cos[u]}, {u, 0, 2 \[Pi]},
  44. AspectRatio -> 1, PlotStyle -> RGBColor[0.925, 0.140, 0.129]];
  45. Print@Plot[Sqrt[z], {t, 0, b trif}, AxesLabel -> {"t", "ra"}];
  46. erp = ParametricPlot[{x, y}, {t, 0, b trif}, AspectRatio -> 1,
  47. PlotRange -> All];
  48. Print@Show[erp, c1, c2];
  49. Goto[3];
  50. Label[2];
  51. Plot[Sqrt[z], {t, 0, b trif}, AxesLabel -> {"t", "ra"}];
  52. Print@ParametricPlot[{x, y}, {t, 0, b trif}, AspectRatio -> 1,
  53. PlotRange -> All];
  54. Label[3];
  55. xp = p[t]/Sqrt[2 T] /. sol;
  56. yp = q[t]/Sqrt[2 T] /. sol;
  57. zp = r[t]/Sqrt[2 T] /. sol;
  58. X = (Cos[u] Sin[v])/Sqrt[A];
  59. Y = (Sin[u] Sin[v])/Sqrt[B];
  60. Z = Cos[v]/Sqrt[C0];
  61. el = ParametricPlot3D[{X, Y, Z}, {u, 0, 2 \[Pi]}, {v, 0, alpha},
  62. Boxed -> False];
  63. pol = ParametricPlot3D[
  64. Evaluate[Flatten[{xp, yp, zp}] /. sol], {t, 0, b trif}];
  65. Print@Show[el, pol]
  66. ]
  67.  
  68. MotiPoin[1, 1.5, 0.5, 3, Pi/4, 1.5, Pi/4]
  69. MotiPoin[1, 1.5, 0.5, 3, 0.01, 1.5, Pi/100]
  70. MotiPoin[0.5, 1.5, 1, -3, 0.01, 3.5, Pi]
  71. MotiPoin[1, 1, 1.5, 3, Pi/4, 2.5, Pi/2]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement