Rotating projectile curve about y-axis
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to create a surface by revolving my x,y plot about the y axis. Basically, it should look like the upper half of a torus. The cuve itself plots the projectile motion of an object.
First code is mine:
close all
clc
x0 = 0;
y0 = 0; % Assume initial height is after impact with surface
t = 0:0.1:10;
g = 9.81;
theta = 45; % Maximum theoretical range in little to no drag
v0 = 10;
x = x0 + v0*cos(theta*(pi()/180))*t;
y = y0 + v0*sin(theta*(pi()/180))*t - 0.5 * g * t.^2
plot(x,y)
ylim([0 inf])
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Second is taken from an author:
close all
clc
% Projectile motion simulation
x0=0; % m
y0=0; % m
v0=10; % m/s
theta=45; % deg
g=9.81; % m/s^2
t_flight=calc_t_flight(g,v0,theta,y0)
range=calc_range(v0,theta,t_flight)
v_impact=calc_v_impact(g,v0,theta,t_flight,y0)
t=linspace(0,t_flight,30);
xdot0=v0*cos(pi*(theta/180));
ydot0=v0*sin(pi*(theta/180));
x=xdot0*t+x0;
y=-(g/2)*t.^2+ydot0*t+y0;
plot(x,y)
axis([0 inf 0 inf])
xlabel(sprintf('Distance (m) - Range = %5.3f',range));
ylabel('Height (m)');
title(sprintf('Projectile motion: v_{impact} = %5.3f m/s',v_impact));
% [X,Y,Z]=cylinder(y);
% surf(Y,Z,X)
% axis ([-10 10 0 10 -10 10])
% xlabel('X');ylabel('Z');zlabel('Y','Rotation',0)
0 commentaires
Réponses (1)
darova
le 6 Avr 2020
You can create a mesh in polar system of coordinates
Assuming
t = linspace(0,2*pi,30); % angle
r = x; % you radius
z = y; % z axis
Z is not chainging in polar system
Use meshgrid to create a mesh
[T,R] = meshgrid(t,r);
[~,Z] = meshgrid(t,z);
Use pol2cart to convert polar coordinate into cartesian
2 commentaires
darova
le 7 Avr 2020
Maybe you understood me in a wrong way
clc
x0 = 0;
y0 = 0; % Assume initial height is after impact with surface
t = 0:0.1:2;
g = 9.81;
theta = 45; % Maximum theoretical range in little to no drag
v0 = 10;
x = x0 + v0*cos(theta*(pi()/180))*t;
y = y0 + v0*sin(theta*(pi()/180))*t - 0.5 * g * t.^2;
t = linspace(0,2*pi,30); % angle
r = x; % you radius
z = y; % z axis
[T,R] = meshgrid(t,r);
[~,Z] = meshgrid(t,z);
[X,Y] = pol2cart(T,R);
surf(Y,Z,X,'facecolor','none')
line(x,y,'linewidth',3)
axis equal vis3d
Voir également
Catégories
En savoir plus sur Polar Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!