Created
March 18, 2021 23:59
-
-
Save lf94/ac4d8ec29abf072308d80b135caa8c8a to your computer and use it in GitHub Desktop.
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
// P = (1−t)2P1 + 2(1−t)tP2 + t2P3 | |
function bezier3(points, segments) = let ( | |
s = 1 / segments | |
) [ | |
for(t = 0; t <= 1 + s; t = t + s) | |
pow((1 - t), 2) * points[0] | |
+ 2 * (1 - t) * t * points[1] | |
+ pow(t, 2) * points[2] | |
]; | |
module heart_half() { | |
fn = 40; | |
translate([0.5 / 2.0, 0, 0]) | |
polygon([ | |
each bezier3([[-0.66, 0], [-1.00, 0.1], [-1.0, 0.35]], fn), | |
each bezier3([[-1.0, 0.35], [-1.0, 1.0], [-0.4, 0.75]], fn), | |
each bezier3([[-0.4, 0.75], [-0.1, 0.55], [0.0, 0.30]], fn), | |
each bezier3([[0.0, 0.30], [0.2, 0.0], [0.25, 0.0]], fn), | |
]); | |
} | |
module heart() { | |
fn = 40; | |
union() { | |
heart_half(); | |
mirror([0, 1, 0]) | |
heart_half(); | |
} | |
} | |
module heart_3d() { | |
translate([0, 0.25, 0]) | |
rotate([90, 90, 0]) | |
linear_extrude(height = 0.5) | |
heart(); | |
} | |
color([1.0, 0.3, 0.3]) { | |
scale([3, 3, 3]) | |
translate([0, 0.5, 0]) | |
rotate([90, 90, 0]) | |
union() { | |
linear_extrude(height = 0.5, scale = [1, 1.5]) | |
heart(); | |
translate([0,0,1]) | |
rotate([180, 0, 0]) | |
linear_extrude(height = 0.5, scale = [1, 1.5]) | |
heart(); | |
} | |
n = 360 / 10; | |
d1 = 5.0; | |
for(i = [0 : n : 360]) { | |
x = cos(i) * d1; | |
y = sin(i) * d1; | |
translate([x, y, 0.0]) | |
rotate([0, 0, i - 90]) | |
heart_3d(); | |
} | |
d2 = 7.0; | |
for(i = [0 : n : 360]) { | |
x = cos(i) * d2; | |
y = sin(i) * d2; | |
translate([x, y, -0.5]) | |
rotate([-90, 0, i - 90]) | |
heart_3d(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment