So im messing around with mathematica and coded a few dynamic graphs of circular motion equations mostly to learn about and practice with mathematica dynamic graphing functions. At the end of the post is the full code of the program.
It outputs 4 sliders and 4 graphs. One after the other. like this :
Out[xxxx]= SLIDER 1
Out[xxxx]= SLIDER 2
Out[xxxx]= GRAPH 1
Out[xxxx]= GRAPH 2
Which is nice for debuging purposes but not so nice to look at since you can't even see all graphs at the same time, which is the whole purpose of the synchronised animations.
Now i have tried all of the notebook formatting options i could think about. even went into a few of the different screen environments (presentation,condensed,slideshow, etc) but they all pretty much look similar in that they all show the same information ( source code + unformatted graphs, sliders) in different styles.
My question is as follows, I would like to create a formatting for an end user such that the user can see and control the sliders but can't see or alter the working source code. most importantly, i would like to format the outputting of the graphs so that they lay on the screen in some way in which all can be seen at the same time. Possibly something like this;
SLIDER SLIDER
SLIDER SLIDER
GRAPH 1 GRAPH 2
GRAPH 3 GRAPH 4.
Basically i want a format that's nice to look at and interact with instead of the rough working format i currently have.
Could someone give me some pointers to good information about how to format mathematica documents to present to an end user ??
is what im asking for even possible ? Im looking for something akin to the nice formatting you get from the wolfram demonstration projects.
I have tried to find info online but am apparently not looking for the right words.
Any help would be appreciated. wether concrete examples or links to a good information source on the topic.
Any other comments on the code itself / possible errors / things to improve are not necessary but obviously welcomed. after all, this is just a project made to learn the mathematica language a little better.
Thanks in advance.
Manuel.T
PS. the code is dynamic but should be safe to run ( only basic mathematica internal variables are modified). Feel free to take a look and play with it. it's pretty fun.
omega = 1;
radius = 1;
theta = 0;
damping = 0;
t = 0;
omegaD := Sqrt[1 - (damping^2)]* omega;
y[t_] := (r*(E^(-damping*omega*t)))*Sin[theta + (omegaD*t)];
x[t_] := (r*(E^(-damping*omega*t))) * Cos[theta + (omegaD*t)];
vy[t_] := y'[t];
ay[t_] := y''[t];
vx[t_] := x'[t];
ax[t_] := x''[t];
pos[t_] := {x[t], y[t]};
vel[t_] := {vx[t], vy[t]};
acc[t_] := {ax[t], ay[t]};
"angular velocity(rad/s)" Slider[Dynamic[omega], {0.1, 2},
Appearance -> "Labeled"]
"Phase offset(rad)" Slider[Dynamic[theta], {0, 2*Pi},
Appearance -> "Labeled"]
"radius(meters)" Slider[Dynamic[r], {1, 100},
Appearance -> "Labeled"]
"damping factor" Slider[Dynamic[damping], {0, 1},
Appearance -> "Labeled"]
position :=
Plot[{ (x[t]), (y[t])}, {t, 0, 2*Pi},
PlotLabel -> HoldForm["position(m)"] ];
velo := Plot[{ vx[t], vy[t]}, {t, 0, 2*Pi},
PlotLabel -> HoldForm["velocity(m/s)"]];
accel := Plot[{ ax[t], ay[t]}, {t, 0, 2*Pi},
PlotLabel -> HoldForm["acceleration(m/s^2)"]];
circle := ParametricPlot[{x[t], y[t]}, {t, 0, ((4*Pi)/omega)},
PlotLabel -> HoldForm["motion"]];
Animate[Show[circle,
Graphics[{PointSize[Large], Red, {Point[Dynamic[{x[t], y[t]}]]},
Blue, Arrow[{pos[t], pos[t] + (vel[t]*0.2)}], Green,
Arrow[{pos[t], pos[t] + (0.2*acc[t])}]}]], {t, 0, 2*Pi,
AppearanceElements -> None, LocalizeVariables -> False}]
Animate[Dynamic[
Show[position,
Graphics[{PointSize[Large],
Red, {Point[Dynamic[{t, y[t]}]],
Point[Dynamic[{t, x[t]}]]}}]]], {t, 0, 2*Pi,
AppearanceElements -> None, LocalizeVariables -> False}]
Animate[
Dynamic[Show[velo,
Graphics[{PointSize[Large],
Red, {Point[Dynamic[{t, vx[t]}]],
Point[Dynamic[{t, vy[t]}]]}}]]], {t, 0, 2*Pi,
AppearanceElements -> None, LocalizeVariables -> False}]
Animate[Dynamic[
Show[accel,
Graphics[{PointSize[Large],
Red, {Point[Dynamic[{t, ax[t]}]],
Point[Dynamic[{t, ay[t]}]]}}]]], {t, 0, 2*Pi,
AppearanceElements -> None, LocalizeVariables -> False}]