Arc travel of a line in 3D space.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Darren Marcelino
le 22 Déc 2022
Commenté : Darren Marcelino
le 20 Jan 2023
So I have a code that moves apoint in an arc throught a 3d space. I thought with my code that the line segment between the points would stay constant since the point just moves in an arc. I tested the arc travel of a line segment in a plane. the line segment would stay constant then.
How come when I try it in a 3d space the line segment length between my two points get smaller? is there a way to keep my line segment constant? am i calculating the travel of the point wrong?
for i=1:length(LowerTheta);
clf
L=9;
ax(i)=8*cosd(LowerTheta(i));
az(i)=8*sind(LowerTheta(i));
%to find beta the angle that the camber links actualyl travel
beta(i)=asind(az(i)/L);
ay(i)=L*cosd(beta(i));
a=[ax(i) ay(i) az(i)];
b=[0 0 0];
w(i)=norm(0-a);
plot3(ax(i),ay(i),az(i),'*r')
grid on
hold on
xlabel('X')
ylabel('y')
set(gca, 'YDir','reverse')
zlabel('z')
plot3(bx,by,bz,'*r')
length(i)=norm(a-b);
pause(.4)
end
disp(length)
0 commentaires
Réponse acceptée
Karim
le 22 Déc 2022
Hi, if I understand you correclty you want to verify the distance between two positions of the point and prefferbaly have it constant? Note that this distance will depend on the input angle (i.e. LowerTheta).
In the code below I modified your code a bit to work vectorized, I plotted the trajectory of the point and evaluate the distance between the consecutive positions.
Looking at your original code, I think the mistake is that you do not update point 'b'. You are always evaluating the length with respact to the origin (i.e. [0,0,0]).
L = 9;
% define some random angles, OP did not provide them
LowerTheta = linspace(0,2*pi,50);
% evaluate the position of the point
ax = 8*cos(LowerTheta);
az = 8*sin(LowerTheta);
ay = L*cosd(asin(az./L));
% create a figure of the trajectory of the point
figure
scatter3(ax(:),ay(:),az(:),'*r')
xlabel('X'); ylabel('Y'); zlabel('Z')
title('Point Trajectory')
grid on
% merge the coordinates into a grid
a = [ax(:) ay(:) az(:)];
% now determine the distance between the consecutive points
SegLength = sqrt( sum( (a(1:end-1,:) - a(2:end,:)).^2 ,2 ))
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Lighting, Transparency, and Shading 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!