Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module toc(r, l, rn=0) {
- rho = (pow(r, 2) + pow(l, 2)) / (2 * r);
- xo = l - sqrt(pow(rho - rn, 2)-pow(rho - r, 2));
- yt = (rn * (rho - r)) / (rho - rn);
- xt = xo - sqrt(pow(rn, 2) - pow(yt, 2));
- rotate_extrude(convexity=10, $fn=128) {
- union() {
- translate([0, l - xo ,0])
- intersection() {
- circle(r=rn, $fn=256);
- square(rn);
- }
- intersection() {
- translate([-rho + r, 0, 0]) circle(r=rho, $fn=256);
- square([r, l - xt]);
- }
- }
- }
- }
- module body_back(w, h, l) {
- rotate([-90, 0, 0]) resize([w, h, l]) difference() {
- toc(w / 2, l);
- translate([-w / 2, 0, -1]) cube([w, w / 2, l + 1]);
- }
- }
- module body_front(w, h, l) {
- resize([w, l, h]) difference() {
- sphere(w / 2);
- translate([-w / 2, 0, -w / 2]) cube([w, w / 2, w]);
- translate([-w / 2, -w / 2, -w / 2]) cube([w, w / 2, w / 2]);
- }
- }
- module body_block(w, h, l, front_part=0.3) {
- body_front(w, h, l * front_part);
- body_back(w, h, l * (1 - front_part));
- }
- module body(w, h, l, th, front_part=0.3, cut_angle=45, cut_ratio=0.2) {
- cut_h = h - (h * cut_ratio);
- a = h * cut_ratio * sin(90 - cut_angle) / sin(cut_angle);
- difference() {
- difference() {
- body_block(w, h, l, front_part);
- body_block(w - th, h - th, l - th, front_part);
- }
- polyhedron([[w / 2, 0, cut_h],
- [w / 2, l, cut_h],
- [-w / 2, l, cut_h],
- [-w / 2, 0, cut_h],
- [w / 2, -a, h],
- [w / 2, l, h],
- [-w / 2, l, h],
- [-w / 2, -a, h]],
- [[0, 1, 2, 3],
- [4, 5, 1, 0],
- [5, 6, 2, 1],
- [6, 7, 3, 2],
- [7, 4, 0, 3],
- [7, 6, 5, 4]]);
- }
- }
- $fn=128;
- body(1000, 700, 2000, 10);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement