Arc travel of a line in 3D space.
2 views (last 30 days)
Show older comments
Darren Marcelino
on 22 Dec 2022
Commented: Darren Marcelino
on 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 Comments
Accepted Answer
Karim
on 22 Dec 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 ))
More Answers (0)
See Also
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!