Which Program is Best for Plotting 3D Trajectories?

Click For Summary
SUMMARY

The discussion centers on the best programs for plotting 3D trajectories, specifically for a mechanics assignment involving the trajectory of a soccer ball. Users recommend MATLAB as the standard tool in the dynamics community, highlighting its plot3 command for 3D plotting. Alternatives such as Maple, FreeMat, and Octave are also mentioned, with FreeMat and Octave being open-source clones of MATLAB. The user expresses a preference for a program that allows for easy manipulation of parameters like wind and air resistance.

PREREQUISITES
  • Familiarity with MATLAB 2023 or similar programming environments
  • Understanding of basic physics concepts related to projectile motion
  • Experience with coding in languages like Java or VB Script
  • Knowledge of 3D plotting techniques
NEXT STEPS
  • Explore MATLAB's plot3 command for 3D trajectory plotting
  • Investigate FreeMat and Octave as alternatives to MATLAB for 3D plotting
  • Learn how to implement parameter switches in MATLAB for dynamic simulations
  • Research additional libraries in Python for 3D plotting, such as Matplotlib or Plotly
USEFUL FOR

This discussion is beneficial for students in mechanics courses, educators looking for effective teaching tools, and developers interested in simulation and visualization of physical systems.

Adoniram
Messages
93
Reaction score
6
Howdy folks,

I have been given the opportunity to do some extra credit for my mechanics class. As an assignment, my prof would like to see a 3D trajectory plotted via a program (like Python).

My basic assignment is to plot the trajectory of a soccer ball after it has been kicked. I don't need help with the physics equations, but I need to know what programs I can use and if one is better than the other. No worries learning the coding language, I have a lot of experience with Java, vb script, etc...

Ideally, I'd like to use a program that has a simple 3D plot of trajectory, and it would be even better if I could save the results as an independent program. If not, no big deal. Also, it would be superb if I could put in switches in the graphical output for things like turning wind on and off, air resistance, etc... If not, I'm sure I can just write multiple programs for each instance.

Thanks!
 
Physics news on Phys.org
I would use Maple (since that's the one I have experience with) or something equivalent to it.
 
MATLAB is generally the standard in the dynamics community. FreeMat and Octave are open source clones of MATLAB.

There is a plot3 command in MATLAB that will do what you want.

Here's an example MATLAB simulation of a mass attached to a spring that behaves as a pendulum; its equations of motion are:
[tex] \begin{align*}<br /> \ddot{r} &= r\dot{\theta}^2 - \frac{k}{m}(r-l) \\<br /> \ddot{\theta} &= -\frac{2\dot{r}\dot{\theta}}{r}<br /> \end{align*}[/tex]
Code:
[i]%% Example simulation of a dynamical system.[/i][/color]
r0 = 1;
l = 1;
rdot0 = rand[/color](1,1);
theta0 = rand[/color](1,1);
thetadot0 = rand[/color](1,1);
x0 = [r0 theta0 rdot0 thetadot0]'[/color];

[t x] = ode45(@pendulum, [0 100], x0);

r = x(:, 1);
theta = x(:, 2);

x = r .*[/color] sin[/color](theta);
y = r .*[/color] cos[/color](theta);

plot(x, y, x(1), y(1), '+g'[/color], x([b]end[/b][/color]), y([b]end[/b][/color]), 'xr'[/color], 'MarkerFaceColor'[/color], 'r'[/color], 'linewidth'[/color], 3);
    tl = title('X-Y Position of Spring-Mass Pendulum'[/color]);
    xl = xlabel('x'[/color]);
    yl = ylabel('y'[/color]);
    set([tl xl yl], 'fontsize'[/color], 16);
    legend('Path'[/color], 'Start'[/color], 'End'[/color], 'Location'[/color], 'NorthEastOutside'[/color]);

Code:
[b]function[/b][/color] [/color] xdot = [/color] pendulum[/color](t, x)
    [/color]m = 1;
    k = 1;
    l = 1;

    r = x(1); theta = x(2); v = x(3); w = x(4);
    xdot = [v;
            w;
            r .*[/color] w.^[/color]2 -[/color] k/[/color]m *[/color] (r -[/color] l);
            -[/color]2 *[/color] v *[/color] w /[/color] r;
    ];
[b]end[/b][/color]

What you want to do will be much simpler than this, but this example should give you a taste of MATLAB.
 
Last edited:

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 6 ·
Replies
6
Views
2K
Replies
4
Views
3K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K