'How to create a 3D plot of a path from equations of motion in wxMaxima?
I have the following equations of motion of a point:
x(t):=r*cos(t^2)$
y(t):=r*sin(t^2)$
z(t):=b*t$
I already calculated the velocities and accelerations but now I would like to plot a path in 3D for this data:
r:5;
b:2;
It should look like a kind of spiral.
I tried various commands to create this 3D plot but none of them worked. All the examples of 3D plots in wxMaxima that I've found are surfaces while in this case, I want to create a curve. Is it possible in this software?
Here are two of the failed attempts:
wxplot3d([x(t), y(t), z(t)], [t, 0, 45]);
wxplot3d([parametric, x(t), y(t), z(t), [t, 0, 45]]);
UPDATE: The command below works but the plot is incorrect for some reason (I attached it as a picture). Is that because of the characteristics of these functions? Do I need some additional input?
wxdraw3d(parametric (x(t), y(t), z(t), t, 0, 45));
UPDATE 2: I tried the following command:
wxdraw3d(nticks = 10, parametric (x(t), y(t), z(t), t, 0, 45));
and the plot looks better (only with nticks=10
):
But it's still not what I would expect. Here's a reference plot from a Polish book describing MathCAD use in mechanics (so I can't utilize the code presented there directly):
Maybe the problem lies in the fact that the authors of this book use some tricks ("auxiliary variables scaling the argument of the function") to obtain the plot. But I assume that it's only necessary in MathCAD. I can be wrong though...
If you know how to define a range variable in Maxima, I can try to replicate the approach from the book in Maxima.
UPDATE 3: Here's what was done in the book to obtain that plot using MathCAD:
define auxiliary variables scaling the argument of the function:
M:=1000
K:=0,1.. 45
for which the time domain is given by:
t_k:=k*sqrt(π/M)
define the functions for plotting as:
X_k:=r*cos(((k^2)/M)*π)
Y_k:=r*sin(((k^2)/M)*π)
Z_k:=b*k
And here's my attempt to translate this to Maxima:
M:1000$
assume(k >= 0, k <= 45);
t_k:k*sqrt(%pi/M);
X_k(t_k):=r*cos(((k^2)/M)*%pi);
Y_k(t_k):=r*sin(((k^2)/M)*%pi);
Z_k(t_k):=b*k;
wxdraw3d(nticks = 10, parametric (X_k(t_k), Y_k(t_k), Z_k(t_k), t_k, 0, 45));
Unfortunately, I get the following error:
draw3d (parametric): non defined variable
That's likely because of the way k
was defined. Can such a range variable be defined differently in Maxima?
Solution 1:[1]
I've adapted the code you showed and it seems to work okay with some modifications.
r:5;
b:2;
M:1000$
X(k):=r*cos(((k^2)/M)*%pi);
Y(k):=r*sin(((k^2)/M)*%pi);
Z(k):=b*k;
draw3d(nticks = 1000, parametric (X(k), Y(k), Z(k), k, 0, 45));
The major changes are that foo_k := ...
in the MathCAD code is translated as foo(k) := ...
in Maxima, and that the plotting variable is k
(which is constructed to vary much more slowly than t
) instead of t
or t(k)
.
Also I increased nticks
by a lot, and cut out the mention of t_k
since it doesn't come into the picture now.
By the way, I think if you say draw3d
in wxMaxima, it will launch an external viewer instead of embedding an image in the notebook (with wxdraw2d
, I think). You can drag with the mouse to rotate the plot in the external viewer, I think. That's helpful with 3-d plots. I could be mistaken about how to launch the viewer, since I don't use wxMaxima very much.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Robert Dodier |