Generating a Rose Window
180 minutesStill a work in progress, but so far promising results…(inspiration)
OpenJSCAD source
1 // title : Rose Window Generator
2 // license : MIT License
3 // revision : 0.1.0
4 // tags : Rose_Window
5 // file : rose_window.jscad
6 function double_circle(radius1, radius2){
7 return circle({r:radius1}).center()
8 .subtract(circle({r:radius2}).center());
9 }
10
11 function ray(radius, width, divisions, invert){
12 rays = [];
13 for (i=0; i < divisions; i++){
14 rays.push(CAG.rectangle({corner1: [0, -width/2], corner2: [radius,width/2]})
15 .rotateZ(i*360/divisions));
16 }
17 return union(rays);
18 }
19
20 function double_rose(radius, circle_radius, circle_inner_radius, divisions){
21 var rose = new CAG();
22 for (i=0;i<divisions;i++){
23 rose = rose.union(double_circle(circle_radius, circle_inner_radius)
24 .translate([radius - circle_radius,0]).rotateZ(i*360/divisions));
25 }
26 return rose;
27 }
28
29 function rose_window(radius, divisions, inner_radius, invert){
30 var outside_circle = circle({r:radius}).center();
31 var rose = new CAG();
32 for (i=0;i<divisions;i++){
33 rose = rose.union(circle({r:(radius-inner_radius)/2}).center()
34 .translate([inner_radius + (radius-inner_radius)/2,0]))
35 .rotateZ(360/divisions);
36 }
37 if (invert === true){
38 rose = outside_circle.subtract(rose);
39 }
40 return rose;
41 }
42 function main() {
43 // still a manual process here, play around with values...
44 return double_circle(20,19)
45 //.subtract(rose_window(22,17, 18,true))
46 .union(double_rose(19.2,6,5.5,14))
47 //.union(rose_window(19,17, 12,false).rotateZ(360/17/2))
48 //.subtract(double_circle(14,9))
49 // .union(rose_window(15,3))
50 // .union(double_circle(13.5,12.5))
51 // .union(double_rose(10,5,4.5,7))
52 // .union(circle({r:5}).center())
53 // .union(ray(14, .5, 14))
54 // .subtract(circle({r:4}).center())
55 .scale(4)
56 // .subtract(rose_window(4, 3, 0, true).center().rotateZ(15))
57 }