0
$\begingroup$

I have a curvature simulation with the help of m_goldberg that works in mathematica but does not work as a cdf in cdf preview. In mathematica it says nothing while in cdf preview or while web embedded says:

Radius radius[0,1] should be a pair of numbers or a scaled Offset factor...same with coordinate r[0,1] and center[0,1].I've been changing the code for a while with no good results.Please Help Thanks

Clear[t]; forms = {{3 Cos[t], 2 Sin[t]}, {Cos[t], Sin[2 t]}};
lbls = ToString /@ forms;
indxs = Range[Length[forms]];
rules = Thread[Rule[indxs, lbls]];
(r[t_, #] = forms[[#]]) & /@ indxs;
(dr[t_, #] = D[r[t, #], t]) & /@ indxs;
(d2r[t_, #] = D[r[t, #], {t, 2}]) & /@ indxs;
(uT[t_, #] = 
     Simplify[dr[t, #]/Norm[dr[t, #]], t \[Element] Reals]) & /@ indxs;
(vN[t_, #] = 
     Simplify[With[{du = D[uT[t, #], t]}, du/Norm[du]], 
      t \[Element] Reals]) & /@ indxs;
(radius[t_, #] = 
     Simplify[
      Norm[dr[t, #]]^3/
       Abs[dr[t, #][[1]] d2r[t, #][[2]] - 
         dr[t, #][[2]] d2r[t, #][[1]]], t \[Element] Reals]) & /@ 
  indxs;
(center[t_, #] = 
     Simplify[r[t, #] + radius[t, #] vN[t, #], 
      t \[Element] Reals]) & /@ indxs;
Manipulate[
 Show[Graphics[{RGBColor[0.6, 0.6, 0.8], 
    Disk[center[t, k], radius[t, k]]}], 
  ParametricPlot[r[t, k], {t, 0, 2 Pi}], 
  Graphics[{PointSize[.025], Point[r[t, k]]}]], {{k, 1, "function"}, 
  rules, ControlType -> PopupMenu}, {t, 0, 2 \[Pi]}]
$\endgroup$
4
  • 2
    $\begingroup$ For starters, add SaveDefinitions->True as option to Manipulate. The problem is that you define your stuff in the global context which is not available inside the Manipulate after you have restarted the Kernel (or open your CDF in the player). $\endgroup$
    – halirutan
    May 28, 2014 at 2:48
  • 1
    $\begingroup$ As per above comment you need to localize these variables and/or investigate Initialization option to Manipulate $\endgroup$ May 28, 2014 at 4:37
  • $\begingroup$ Unless the simple mistake imo it can be marked asa duplicate of understanding CDF $\endgroup$
    – Kuba
    May 28, 2014 at 4:50
  • $\begingroup$ I overlooked the easiest part. SaveDefinitions totally works.Thanks so much!!!! $\endgroup$
    – user14520
    May 28, 2014 at 5:35

0

Browse other questions tagged or ask your own question.