How to join a clothoid and an circular arc for a smooth transition?
28 views (last 30 days)
Show older comments
Hey,
I want to create a trajectory for a right turn driving scenario and have calculated x and y coordinates for a clothoid and a circular arc. I can not use Matlab toolboxes, which is why I used series development of sin and cos for the clothoid. As you can see in the picture, there is a change of curvature where I wanted to match up the clothoid and the arc (around x = 6.3 and y = -0.8).
How can I change my code, so there will be a smooth transition for the curvature? I also attached my code.

For the clothoid I used values given in the Euro NCAP Test Protocol from 2023. The clothoid should start with a radius of 1500 m and end with a radius of 8 m to match the radius of the circular arc. The angles are also given, see the picture below for more info.

Thank you so much!
Jane
1 Comment
slim
on 18 Aug 2025
Hi Jane
I am working currently on project as yours (creating NCAP/vehicle dynamic scenarios in odr and osc) and want to get an insight on the problems and troubles you gone through before I start. Of course if this suits you
Thanks in advance.
Slim
Accepted Answer
Mathieu NOE
on 6 Oct 2023
hello
see below your code fixed ; the only error is that when you create the constant radius (circle) segment , your initial angle is not alpha but the angle of the tangent vector of the previous segment (the first clothoid) where it ends. This angle value is obtained by these two new lines of code :
% final angle of 1st clothoid (tangent vector)
clothoid_ang = atan2(diff(clothoid_y),diff(clothoid_x));
clothoid_ang = clothoid_ang(end);
So replace alpha by -clothoid_ang as the arc segment start angle . The minus sign is because you have a y downward going curve (is it intentionnal ?)
full code :
% simulation parameters
v_ego_value_run = 10; % 10 km/h, vehicle should maintain a constant velocity
% scenario parameters
v_ego_value = v_ego_value_run/3.6; % in m/s
tstep = 0.1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Clothoid parameters
start_radius = 1500; % Starting radius in meters
end_radius = 8; % Ending radius in meters
alpha_deg = 22.85; % Angle in degrees
beta_deg = 44.3;
% Convert angle from degrees to radians
alpha = deg2rad(alpha_deg);
beta = deg2rad(beta_deg);
% calculate length of clothoid
clothoid_length = (alpha*2*end_radius)/(1-(end_radius/start_radius)^2);
% Number of points to calculate
clothoid_time = clothoid_length/v_ego_value;
clothoid_tsteps = clothoid_time/tstep;
L = round(clothoid_tsteps);
% Initialize arrays for series expansion
n = 10;
T_end = clothoid_length/(2*end_radius);
a = zeros(1, n);
b = zeros(1, n);
a_0 = 1;
% Initialize arrays to store x and y coordinates
clothoid_x = zeros(1, n);
clothoid_y = zeros(1, n);
% series expansion for cos and sin
len_cloth = linspace(0,clothoid_length,L);
for k = 1:L; l = len_cloth(k);
T = l/(2*end_radius);
for i = 1:n
a(i) = (-1)^i * T^(2*i)/(factorial(2*i)*(4*i+1));
end
cosT = sum(a) + a_0;
clothoid_x(k) = l*cosT;
end
for k = 1:L; l = len_cloth(k);
T = l/(2*end_radius);
b_0 = T/3;
for i = 1:n
b(i) = (-1)^i * T^(2*i+1)/(factorial(2*i+1)*(4*i+3));
end
sinT = sum(b) + b_0;
clothoid_y(k) = -l*sinT;
end
% clothoid = [clothoid_x;clothoid_y]; % not needed as you have already
% clothoid_x and clothoid_y variables
figure
plot(clothoid_x,clothoid_y)
grid on
axis equal
hold on
% final angle of 1st clothoid (tangent vector)
clothoid_ang = atan2(diff(clothoid_y),diff(clothoid_x));
clothoid_ang = clothoid_ang(end);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% circular arc
arc_length = end_radius*beta;
arc_time = arc_length/v_ego_value;
arc_tsteps = arc_time/tstep;
len_arc = linspace(0,arc_length,round(arc_tsteps));
% theta = linspace(alpha,beta+alpha,length(len_arc));
theta = linspace(-clothoid_ang,beta-clothoid_ang,length(len_arc));
arc_y_center = end_radius * cos(theta);
arc_x_center = end_radius * sin(theta);
%plot(arc_x_center,arc_y_center)
% y_offset = arc_y_center(1)-clothoid(2,end); % same remark as above
% x_offset = arc_x_center(1)-clothoid(1,end); % same remark as above
y_offset = arc_y_center(1)-clothoid_y(end);
x_offset = arc_x_center(1)-clothoid_x(end);
arc_y = arc_y_center - y_offset;
arc_x = arc_x_center - x_offset;
%plot(arc_x,arc_y)
% merge trajectories
arc_y(1) = []; % delete overlapping values
arc_x(1) = [];
vehicle_y_pos = [clothoid_y arc_y];
vehicle_x_pos = [clothoid_x arc_x];
plot(vehicle_x_pos,vehicle_y_pos);
5 Comments
Mathieu NOE
on 29 Apr 2024
probably a question the OP can better answer than me - I have not used clothoid maths for the last 30 years
More Answers (0)
See Also
Categories
Find more on Time Series Events in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!