Created
September 29, 2021 15:28
-
-
Save christianvdstap/7378eada5b23d49b0ec7846494e55227 to your computer and use it in GitHub Desktop.
My sanity just left me
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function road_points() = | |
let(p=perimeter_points(), | |
p1=p[1], | |
p2=p[2], | |
p3=p[3], | |
pn=p[len(p)-1], | |
rb=road_width_b/2, | |
ra=road_width_a/2, | |
la=length_vector(pn), | |
// Scale vector pn with road radius b | |
a=scale_vector(pn,(la-rb)/la), | |
o=big_circle_origin(), | |
// Define 2 vectors for the line parallel to p2-p3 with road radius a | |
pp2=p2+perpendicular_point(p3,p2,ra), | |
pp3=p3+perpendicular_point(p3,p2,ra), | |
// Determine intersection point for point b | |
b=circle_line_intersection(pp2-o,pp3-o,radius_big_circle+rb)[1]+o, | |
lc=length_vector(p2-p1), | |
c=scale_vector(p2-p1, (lc-ra/cos(39))/lc)+p1, | |
ld=length_vector(p3-p2), | |
d=scale_vector(p3-p2,(ld-rb)/ld)+p2, | |
cp=calculate_center_arch_point(d,a,radius_big_circle+rb), | |
curve=bezier_curve_points([a,cp,d],20) | |
) | |
concat( | |
[for(i = [2:len(p)-1]) p[i]], | |
[a], | |
filter(curve, function(p) p[0] < b[0]), | |
[b], | |
[c] | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment