Helical trajectory generation using frenet frame
4 views (last 30 days)
Show older comments
How to generate a helical trajectory using frenet frame? Position vector given as [x y z]^T=[[500sin(0.01t) 500cos(0.01t) −2t−20000]^T initial position is ζ (0) = [−300 0 −19800]^T initial line velocity is υ(0) =[5 0 0]^T, the initial attitude is γ (0) = [0, 0, 0]^T How to convert this data to frenet frame and find attitude coordinates and then plot a helical trajectory
0 Comments
Answers (1)
Vaibhav
on 28 May 2024
Hi Dhishya
To generate the helical trajector using frenet frame. We first define the helical trajectory using the given position vector. Then, we calculate the velocity and acceleration to derive the Frenet frame vectors (Tangent, Normal, Binormal). Finally, we can plot the trajectory and the Frenet frame vectors for visualization.
Here is the code for your reference:
% Define the trajectory
t = linspace(0, 20000, 10000);
x = 500*sin(0.01*t);
y = 500*cos(0.01*t);
z = -2*t - 20000;
% Calculate derivatives for velocity and acceleration
dx = gradient(x, t);
dy = gradient(y, t);
dz = gradient(z, t);
ddx = gradient(dx, t);
ddy = gradient(dy, t);
ddz = gradient(dz, t);
% Calculate Frenet frame vectors
T = [dx; dy; dz];
T_norm = sqrt(dx.^2 + dy.^2 + dz.^2);
T_unit = T ./ T_norm;
dTx = gradient(T(1,:), t);
dTy = gradient(T(2,:), t);
dTz = gradient(T(3,:), t);
N = [dTx; dTy; dTz];
N_norm = sqrt(dTx.^2 + dTy.^2 + dTz.^2);
N_unit = N ./ N_norm;
B = cross(T, N);
B_norm = sqrt(B(1,:).^2 + B(2,:).^2 + B(3,:).^2);
B_unit = B ./ B_norm;
% Plot the trajectory and Frenet frame vectors
figure;
plot3(x, y, z, 'LineWidth', 2);
hold on;
quiver3(x(1:100:end), y(1:100:end), z(1:100:end), T_unit(1,1:100:end), T_unit(2,1:100:end), T_unit(3,1:100:end), 'r');
quiver3(x(1:100:end), y(1:100:end), z(1:100:end), N_unit(1,1:100:end), N_unit(2,1:100:end), N_unit(3,1:100:end), 'g');
quiver3(x(1:100:end), y(1:100:end), z(1:100:end), B_unit(1,1:100:end), B_unit(2,1:100:end), B_unit(3,1:100:end), 'b');
xlabel('X');
ylabel('Y');
zlabel('Z');
title('Helical Trajectory with Frenet Frame');
legend('Trajectory', 'Tangent', 'Normal', 'Binormal');
grid on;
axis equal;
Hope it helps!
0 Comments
See Also
Categories
Find more on Mathematics and Optimization 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!