owl.scad
1 use <polyhedra/polar_zonohedra.scad> 2 use <polyhedra/octahedron.scad> 3 use <polyhedra/icosahedron.scad> 4 use <shear.scad> 5 use <polyline_join.scad> 6 use <bezier_curve.scad> 7 use <matrix/m_transpose.scad> 8 use <sweep.scad> 9 use <experimental/worley_sphere.scad> 10 use <curve.scad> 11 use <ptf/ptf_rotate.scad> 12 use <util/dedup.scad> 13 14 detail = 1; 15 head_angles = [5, 0, 20]; 16 17 owl(detail, head_angles); 18 rock(detail); 19 20 // translate([100, 0, 0]) { 21 // owl(detail, [-15, 0, -20]); 22 // rock(detail); 23 // } 24 25 // translate([-100, 0, 0]) { 26 // owl(detail, [-35, 0, 30]); 27 // rock(detail); 28 // } 29 30 module owl(detail, head_angles) { 31 n = (detail + 1) * 5; 32 $fn = n; 33 34 module head() { 35 module eye_plane_mask() { 36 translate([10, -17, 0]) 37 rotate([90, 0, 30]) 38 linear_extrude(10) 39 circle(12); 40 } 41 42 module eye_ring() { 43 translate([10, -16, 0]) 44 rotate([270, 0, 30]) 45 scale([1, 1, 2]) 46 rotate(180 / $fn) 47 rotate_extrude() 48 translate([12, 0, 0]) 49 circle(1.75); 50 } 51 52 module eye_hole_mask() { 53 translate([10, -17, 0]) 54 rotate([270, 0, 30]) 55 rotate(180 / $fn) 56 translate([0, 0, -1]) 57 linear_extrude(3, scale = .5) 58 circle(10); 59 } 60 61 module eye_ball() { 62 translate([8, -13, 0]) 63 icosahedron(4, n / 5 - 1); 64 } 65 66 difference() { 67 union() { 68 difference() { 69 rotate([15, 0, 0]) 70 shear(sy = [0, -.05]) 71 scale([25, 25, 25]) 72 octahedron(1, n / 5); 73 74 eye_plane_mask(); 75 mirror([1, 0, 0]) 76 eye_plane_mask(); 77 } 78 79 eye_ring(); 80 mirror([1, 0, 0]) 81 eye_ring(); 82 } 83 84 eye_hole_mask(); 85 mirror([1, 0, 0]) 86 eye_hole_mask(); 87 } 88 89 eye_ball(); 90 mirror([1, 0, 0]) 91 eye_ball(); 92 93 eyebrow(); 94 mirror([1, 0, 0]) 95 eyebrow(); 96 97 // beak 98 translate([0, -23.25, -2.5]) 99 scale([.85, 1, 3.5]) 100 rotate([25, 0, 0]) 101 octahedron(2.5, detail); 102 } 103 104 module body() { 105 // back 106 translate([0, 57, 22]) 107 rotate([68, 0, 0]) 108 shear(sy = [0, .3]) 109 scale([110, 100, 150] / n) 110 polar_zonohedra(n); 111 112 113 // belly 114 translate([0, 14, 22]) 115 rotate([5, 0, 0]) 116 scale([100, 90, 120] / n) 117 polar_zonohedra(n); 118 119 translate([0, 56.5, 15]) 120 rotate([12, 0, 0]) 121 shear(sy = [0, -1]) 122 scale([90, 90, 100] / n) 123 polar_zonohedra(n); 124 125 // tail 126 translate([0, 69, 9]) 127 rotate([12, 0, 0]) 128 shear(sz = [0, .1]) 129 shear(sy = [0, -1.1]) 130 scale([80, 80, 110] / n) 131 polar_zonohedra(n); 132 133 translate([4, 69, 11]) 134 rotate([12, 0, 2]) 135 shear(sz = [0, .1]) 136 shear(sy = [0, -1.1]) 137 scale([60, 60, 100] / n) 138 polar_zonohedra(n); 139 } 140 141 module wing() { 142 translate([2, 61, 25]) 143 rotate([68, 5, 0]) 144 shear(sz = [0, .3]) 145 shear(sy = [0, .2]) 146 scale([120, 100, 140] / n) 147 polar_zonohedra(n); 148 } 149 150 module eyebrow() { 151 t_step = 0.2 / detail; 152 points = bezier_curve(t_step, [[0, -25, 0.5], [5, -26, 14.5], [15, -21, 7.5], [25, -6, 22.5]]); 153 points2 = bezier_curve(t_step, [[0, -25, 0.5], [5, -26, 12.5], [20, -16, -0.5], [25, -6, 22.5]]); 154 points3 = bezier_curve(t_step, [[0, -25, 0.5], [5, -11, 12.5], [15, -16, 9.5], [25, -6, 22.5]]); 155 points4 = bezier_curve(t_step, [[0, -25, 0.5], [-5, -23, 17.5], [15, -21, 14.5], [25, -6, 22.5]]); 156 157 sweep( 158 m_transpose([points4, points3, points2, points]) 159 ); 160 } 161 162 module claw() { 163 pts = [ 164 [0, 0.55], [1, 0.45], [2.5, 0.375], [6, 0.825], [8, -0.375], 165 [8, -0.375], [6, 1.875], [4, 1.6], [1.8, 2.5], [1.5, 2.8], [1.2, 3.3], [1.05, 3.8], [1, 4], [0, 8] 166 ]; 167 168 $fn = 16; 169 170 a = 360 / $fn; 171 x = 6.2 * cos(a); 172 y = 6.2 * sin(a); 173 path = [ 174 [0, 0], [2.5, 0], [x, y], [x + 1, y + 1] 175 ]; 176 path2 = [ 177 for(i = len(path) - 1; i > -1; i = i - 1) 178 ptf_rotate([path[i][0], -path[i][1]], a * 2) 179 ]; 180 181 t_step = 0.25; 182 claw_path_basic = concat(curve(t_step, path), curve(t_step, path2)); 183 184 claw_path1 = [for(p = claw_path_basic) ptf_rotate(p * 1.2, a * 2)]; 185 claw_path2 = [for(p = claw_path_basic) ptf_rotate(p * 1.15, a * 4)]; 186 claw_path3 = [for(p = claw_path_basic) ptf_rotate(p * 1.1, a * 6)]; 187 claw_path4 = [for(p = claw_path_basic) ptf_rotate(p, a * 12)]; 188 189 translate([10, 19, 18]) 190 scale([1.2, 1.2, 1.5]) 191 rotate([10, 0, 180]) 192 scale([1.15, 1.3, 1]) 193 intersection() { 194 rotate_extrude($fn = 7) 195 polygon(pts); 196 linear_extrude(5) 197 polygon( 198 dedup( 199 [ 200 each claw_path1, 201 each claw_path2, 202 each claw_path3, 203 [-2, -.75], 204 [-1.45, -1.45], 205 each claw_path4, 206 [1.45, -1.45], 207 [2, -.75] 208 ] 209 ) 210 ); 211 } 212 } 213 214 translate([0, 0, 82.5]) 215 rotate(head_angles) 216 head(); 217 218 body(); 219 220 wing(); 221 mirror([1, 0, 0]) 222 wing(); 223 224 claw(); 225 mirror([1, 0, 0]) 226 claw(); 227 } 228 229 module rock(detail) { 230 radius = 16.5; 231 detail = detail; 232 amplitude = .25; 233 dist = "border"; 234 235 difference() { 236 translate([1, 20, -6.9]) 237 scale([1, 1.2, 1]) 238 rotate([35, 3, 0]) 239 translate([0, 0, 12]) 240 scale([3, 1, 1]) 241 worley_sphere(radius, detail, amplitude, dist, seed = 4); 242 243 translate([0, 34, -30]) 244 linear_extrude(30) 245 square(150, center = true); 246 } 247 } 248 249