diff vs bare: +51/-80
- // Mug with hollow interior and ring handle
+ // Mug with hollow interior and radial ring handle
$fn = 128;
- outer_d = 80;
- outer_r = outer_d/2;
+ // Given dimensions
+ outer_d = 80; // outside diameter
+ body_h = 100; // height
+ wall_t = 4; // side wall thickness
+ bottom_t = 6; // bottom thickness
- body_h = 100;
- wall_t = 4;
-
- bottom_t = 6;
-
- handle_r = 12; // radius of the ring handle (extrudes outward from the cup)
- handle_th = 10; // handle ring thickness (in the Z direction after rotation)
- handle_z = 50; // center height of the handle on the mug
-
+ outer_r = outer_d/2;
inner_r = outer_r - wall_t;
- inner_h = body_h - bottom_t; // hollow starts above the bottom thickness
- module ring_handle(r=12, z=50, ring_th=10, hole_d=18){
- // A ring (torus-like) oriented so it protrudes radially from the cup wall.
- // We'll create it by rotating a 2D annulus profile around the X axis direction.
- // In this construction, the ring's center is at the mug's side (x = outer_r),
- // so we translate it outward by r.
- rotate([0,90,0]) // rotate so ring is in Y-Z plane and protrudes in +X
- translate([0,0,0])
- difference(){
- // Outer torus (generated by revolving a circle)
- torus( rOuter=r + ring_th, rInner=r + ring_th - 1, z=z);
- }
- }
+ // Handle requirements
+ handle_radius_extrude = 12; // ring's radius that protrudes outward (radially)
+ handle_th = 10; // ring thickness (height in Z)
+ handle_z = body_h/2; // center height of handle
- // Helper: create a torus by sweeping a circle along a radius
- module torus(rOuter, rInner, z=0){
- // rOuter: major radius, rInner: minor radius (approx using outer circle - inner circle)
- // We'll implement as a difference of two spheres swept by linear_extrude? Instead use rotate_extrude annulus:
- // Use rotate_extrude with an annulus cross-section positioned at radius rOuter.
- // Minor radius approximated: use (rOuter - rInner) as thickness; if small, still fine.
- minor = max(0.1, (rOuter - rInner));
- // Cross-section: circle(s) of radius minor about origin, then translate out by rOuter
- // We'll build as an annulus torus: outer and inner subtraction.
- difference(){
- rotate_extrude(angle=360)
- translate([rOuter, 0, z])
- circle(r=minor);
- // inner cut to form ring hole (if ring thickness enough)
- if (minor - 3 > 0)
- rotate_extrude(angle=360)
- translate([rOuter, 0, z])
- circle(r=minor-3);
- }
- }
-
- module mug(){
- difference(){
- // Outer body
+ // -------------------- Geometry --------------------
+ module mug() {
+ // Outer shell
+ difference() {
cylinder(h=body_h, r=outer_r);
- // Hollow interior
+ // Hollow interior (keep bottom thickness)
translate([0,0,bottom_t])
- cylinder(h=inner_h, r=inner_r);
+ cylinder(h=body_h - bottom_t, r=inner_r);
}
}
- difference(){
- // Mug body
- mug();
+ module ring_handle(rad=12, zc=50, ring_th=10, hole=6) {
+ /*
+ Radial ring oriented so it protrudes in +X direction from the cup wall.
+ Implemented as a torus whose major radius is 'rad' and whose minor
+ radius is ring_th/2, then cut out an inner hole to make it a ring
+ (so a finger can pass).
+
+ Position: center of ring cross-section is located at the cup's outer
+ surface plane (x=outer_r), and the ring extends further outward
+ to x=outer_r + rad*2 (i.e., "外径方向に飛び出す").
+ */
+ minor_outer = ring_th/2;
- // No subtractive operations beyond the hollow are needed here;
- // keep handle addition outside this difference to remain simple.
+ // Safety for subtraction
+ minor_inner = max(0.1, minor_outer - hole);
+
+ // Torus constructed from rotate_extrude of an annulus cross-section.
+ // Major radius uses translate([rad,0,z]) before rotate_extrude.
+ rotate([0,90,0]) // make torus axis align such that it protrudes radially in +X
+ translate([outer_r, 0, zc])
+ difference() {
+ // Outer torus
+ rotate_extrude(angle=360)
+ translate([rad, 0, 0])
+ circle(r=minor_outer);
+
+ // Inner cutout (hole)
+ rotate_extrude(angle=360)
+ translate([rad, 0, 0])
+ circle(r=minor_inner);
+ }
}
- // Add handle as a union with the mug
- union(){
+ union() {
mug();
-
- // Handle ring placement:
- // Place ring so it protrudes outward from the cup side.
- // We'll position the ring center at (x=outer_r + handle_r/2, y=0, z=handle_z),
- // with the ring's axis along the radial direction via rotation.
- //
- // Use a torus created from an annulus profile with major radius = handle_r
- // and minor radius controlled by handle_th.
- //
- // We'll center the ring at the cup's side by translating its major radius beyond outer_r.
- translate([outer_r + (handle_r/2), 0, handle_z])
- rotate([0,90,0])
- difference(){
- // Outer ring (torus-like)
- rotate_extrude(angle=360)
- translate([handle_r, 0, 0])
- circle(r=handle_th/2);
- // Inner hole
- rotate_extrude(angle=360)
- translate([handle_r, 0, 0])
- circle(r=handle_th/2 - 2.5);
- }
+ // Place handle at cup center height, centered on the outer wall plane,
+ // protruding outward with major radius=12.
+ ring_handle(rad=handle_radius_extrude, zc=handle_z, ring_th=handle_th, hole=6);
}
SCAD (68 lines)
// Mug with hollow interior and radial ring handle
$fn = 128;
// Given dimensions
outer_d = 80; // outside diameter
body_h = 100; // height
wall_t = 4; // side wall thickness
bottom_t = 6; // bottom thickness
outer_r = outer_d/2;
inner_r = outer_r - wall_t;
// Handle requirements
handle_radius_extrude = 12; // ring's radius that protrudes outward (radially)
handle_th = 10; // ring thickness (height in Z)
handle_z = body_h/2; // center height of handle
// -------------------- Geometry --------------------
module mug() {
// Outer shell
difference() {
cylinder(h=body_h, r=outer_r);
// Hollow interior (keep bottom thickness)
translate([0,0,bottom_t])
cylinder(h=body_h - bottom_t, r=inner_r);
}
}
module ring_handle(rad=12, zc=50, ring_th=10, hole=6) {
/*
Radial ring oriented so it protrudes in +X direction from the cup wall.
Implemented as a torus whose major radius is 'rad' and whose minor
radius is ring_th/2, then cut out an inner hole to make it a ring
(so a finger can pass).
Position: center of ring cross-section is located at the cup's outer
surface plane (x=outer_r), and the ring extends further outward
to x=outer_r + rad*2 (i.e., "外径方向に飛び出す").
*/
minor_outer = ring_th/2;
// Safety for subtraction
minor_inner = max(0.1, minor_outer - hole);
// Torus constructed from rotate_extrude of an annulus cross-section.
// Major radius uses translate([rad,0,z]) before rotate_extrude.
rotate([0,90,0]) // make torus axis align such that it protrudes radially in +X
translate([outer_r, 0, zc])
difference() {
// Outer torus
rotate_extrude(angle=360)
translate([rad, 0, 0])
circle(r=minor_outer);
// Inner cutout (hole)
rotate_extrude(angle=360)
translate([rad, 0, 0])
circle(r=minor_inner);
}
}
union() {
mug();
// Place handle at cup center height, centered on the outer wall plane,
// protruding outward with major radius=12.
ring_handle(rad=handle_radius_extrude, zc=handle_z, ring_th=handle_th, hole=6);
}