MATLAB: Drawing a birdseye view of a velodrome

drawingvelodrome

I want to be able to draw a birds eye view of a cycling velodrome. In another words, I want to be able to put in the lengths of the straights which are identical and parralell and the radius of a circle that joins the straights at each end. I have no idea how to do this as it is "two shapes in one" Any help appreciated.

Best Answer

Experiment with this:
t1 = linspace(0, pi, 25);
t2 = linspace(pi, 2*pi, 25);
r = 2.5; % Radius Of Circles
d = 5; % Length Of Straights
crcx = @(r,t) r*cos(t);
crcy = @(r,t) r*sin(t);
figure
hold on
plot(crcx(r,t1), crcy(r,t1))
plot(crcx(r,t1), crcy(-r,t1)-d)
plot([crcx(r,t1(end)) crcx(r,t1(end))], [crcy(r,t1(end)) crcy(r,t2(end))-d])
plot([crcx(r,t1(1)) crcx(r,t1(1))], [crcy(r,t1(end)) crcy(r,t2(end))-d])
hold off
axis equal
producing:
Drawing a birdseye view of a velodrome- 2019 12 29.png
I left the lines different colours to help explain how the code works.