discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

How make this flat instead of a cylinder

TO
Trevor Orr
Sun, Jan 12, 2025 9:34 PM

I used an AI system to create this, it is for the most part exactly what I what but instead of it being a sphere going around and up I want it to be a flat bar the same size as the sphere.  Any easy way of doing this?
Here is the code it generated, I modified this a little bit.

// Parametersnum_points=500;initial_diameter = 200;  // base diameterheight = 75;  // Total height (3 rounds × 25mm per round)diameter_decrease = 25;  // 25mm decrease per roundnum_holes = 120;spiral_thickness = 10;  // Thickness of the spiral pathhole_diameter = 3;  // 3mm holes

// Function to calculate points along the spiralfunction spiral_points(steps) = [    for(i = [0:steps-1])    let(        angle = i * 360 * 5 / steps,  // 5 complete rotations        radius = (initial_diameter - (angle/360) * diameter_decrease) / 2,        z = (height * angle) / (360 * 5)    )    [        radius * cos(angle),        radius * sin(angle),        z    ]];
// Function to create points for a hole at a given position and normalfunction rotate_points(points, normal, center) =    let(        angle = atan2(normal[1], normal[0]),        elevation = atan2(normal[2], sqrt(normal[0] * normal[0] + normal[1] * normal[1]))    )    [        for(p = points)        let(            rotated =                 [[1, 0, 0], [0, cos(elevation), -sin(elevation)], [0, sin(elevation), cos(elevation)]] *                [[cos(angle), -sin(angle), 0], [sin(angle), cos(angle), 0], [0, 0, 1]] *                p        )        [            rotated[0] + center[0],            rotated[1] + center[1],            rotated[2] + center[2]        ]    ];
// Create the main spiralmodule spiral() {    points = spiral_points(num_points);  // Generate 500 points along the spiral        // Create the spiral path    for(i = [0:len(points)-2]) {        hull() {            translate(points[i])                sphere(d=spiral_thickness, $fn=20);            translate(points[i+1])                sphere(d=spiral_thickness, $fn=20);        }    }}
// Create holes along the spiralmodule holes() {    points = spiral_points(num_holes);        for(i = [0:len(points)-2]) {        // Calculate direction vector for hole orientation        vector = points[i+1] - points[i];        length = norm(vector);        normal = vector / length;                // Create hole        translate(points[i]) {            // Create a cylinder oriented along the normal vector            hole_points = rotate_points(                [for(z = [-15:15]) [0, 0, z]],                normal,                [0, 0, 0]            );                        hull() {                for(p = hole_points) {                    translate(p)                        sphere(d=hole_diameter, $fn=16);                }            }        }    }}
// Final modeldifference() {    spiral();    holes();}

I used an AI system to create this, it is for the most part exactly what I what but instead of it being a sphere going around and up I want it to be a flat bar the same size as the sphere.  Any easy way of doing this? Here is the code it generated, I modified this a little bit. // Parametersnum_points=500;initial_diameter = 200;  // base diameterheight = 75;  // Total height (3 rounds × 25mm per round)diameter_decrease = 25;  // 25mm decrease per roundnum_holes = 120;spiral_thickness = 10;  // Thickness of the spiral pathhole_diameter = 3;  // 3mm holes // Function to calculate points along the spiralfunction spiral_points(steps) = [    for(i = [0:steps-1])    let(        angle = i * 360 * 5 / steps,  // 5 complete rotations        radius = (initial_diameter - (angle/360) * diameter_decrease) / 2,        z = (height * angle) / (360 * 5)    )    [        radius * cos(angle),        radius * sin(angle),        z    ]]; // Function to create points for a hole at a given position and normalfunction rotate_points(points, normal, center) =    let(        angle = atan2(normal[1], normal[0]),        elevation = atan2(normal[2], sqrt(normal[0] * normal[0] + normal[1] * normal[1]))    )    [        for(p = points)        let(            rotated =                 [[1, 0, 0], [0, cos(elevation), -sin(elevation)], [0, sin(elevation), cos(elevation)]] *                [[cos(angle), -sin(angle), 0], [sin(angle), cos(angle), 0], [0, 0, 1]] *                p        )        [            rotated[0] + center[0],            rotated[1] + center[1],            rotated[2] + center[2]        ]    ]; // Create the main spiralmodule spiral() {    points = spiral_points(num_points);  // Generate 500 points along the spiral        // Create the spiral path    for(i = [0:len(points)-2]) {        hull() {            translate(points[i])                sphere(d=spiral_thickness, $fn=20);            translate(points[i+1])                sphere(d=spiral_thickness, $fn=20);        }    }} // Create holes along the spiralmodule holes() {    points = spiral_points(num_holes);        for(i = [0:len(points)-2]) {        // Calculate direction vector for hole orientation        vector = points[i+1] - points[i];        length = norm(vector);        normal = vector / length;                // Create hole        translate(points[i]) {            // Create a cylinder oriented along the normal vector            hole_points = rotate_points(                [for(z = [-15:15]) [0, 0, z]],                normal,                [0, 0, 0]            );                        hull() {                for(p = hole_points) {                    translate(p)                        sphere(d=hole_diameter, $fn=16);                }            }        }    }} // Final modeldifference() {    spiral();    holes();}
DP
Dan Perry
Sun, Jan 12, 2025 9:54 PM

I didn't try out your code, but it looks like you should replace sphere()
twice in module spiral() with cube().  To be closer to a perfect flat bar,
you would need to x-rotate (or possibly y-rotate) the cube() by the value
of angle in module spiral_points().
Dan

On Sun, Jan 12, 2025 at 9:34 PM Trevor Orr via Discuss <
discuss@lists.openscad.org> wrote:

I used an AI system to create this, it is for the most part exactly what I
what but instead of it being a sphere going around and up I want it to be a
flat bar the same size as the sphere.  Any easy way of doing this?

Here is the code it generated, I modified this a little bit.

// Parameters
num_points=500;
initial_diameter = 200;  // base diameter
height = 75;  // Total height (3 rounds × 25mm per round)
diameter_decrease = 25;  // 25mm decrease per round
num_holes = 120;
spiral_thickness = 10;  // Thickness of the spiral path
hole_diameter = 3;  // 3mm holes

// Function to calculate points along the spiral
function spiral_points(steps) = [
for(i = [0:steps-1])
let(
angle = i * 360 * 5 / steps,  // 5 complete rotations
radius = (initial_diameter - (angle/360) * diameter_decrease) / 2,
z = (height * angle) / (360 * 5)
)
[
radius * cos(angle),
radius * sin(angle),
z
]
];

// Function to create points for a hole at a given position and normal
function rotate_points(points, normal, center) =
let(
angle = atan2(normal[1], normal[0]),
elevation = atan2(normal[2], sqrt(normal[0] * normal[0] +
normal[1] * normal[1]))
)
[
for(p = points)
let(
rotated =
[[1, 0, 0], [0, cos(elevation), -sin(elevation)], [0,
sin(elevation), cos(elevation)]] *
[[cos(angle), -sin(angle), 0], [sin(angle), cos(angle),
0], [0, 0, 1]] *
p
)
[
rotated[0] + center[0],
rotated[1] + center[1],
rotated[2] + center[2]
]
];

// Create the main spiral
module spiral() {
points = spiral_points(num_points);  // Generate 500 points along the
spiral

 // Create the spiral path
 for(i = [0:len(points)-2]) {
     hull() {
         translate(points[i])
             sphere(d=spiral_thickness, $fn=20);
         translate(points[i+1])
             sphere(d=spiral_thickness, $fn=20);
     }
 }

}

// Create holes along the spiral
module holes() {
points = spiral_points(num_holes);

 for(i = [0:len(points)-2]) {
     // Calculate direction vector for hole orientation
     vector = points[i+1] - points[i];
     length = norm(vector);
     normal = vector / length;

     // Create hole
     translate(points[i]) {
         // Create a cylinder oriented along the normal vector
         hole_points = rotate_points(
             [for(z = [-15:15]) [0, 0, z]],
             normal,
             [0, 0, 0]
         );

         hull() {
             for(p = hole_points) {
                 translate(p)
                     sphere(d=hole_diameter, $fn=16);
             }
         }
     }
 }

}

// Final model
difference() {
spiral();
holes();
}


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I didn't try out your code, but it looks like you should replace sphere() twice in module spiral() with cube(). To be closer to a perfect flat bar, you would need to x-rotate (or possibly y-rotate) the cube() by the value of angle in module spiral_points(). Dan On Sun, Jan 12, 2025 at 9:34 PM Trevor Orr via Discuss < discuss@lists.openscad.org> wrote: > I used an AI system to create this, it is for the most part exactly what I > what but instead of it being a sphere going around and up I want it to be a > flat bar the same size as the sphere. Any easy way of doing this? > > Here is the code it generated, I modified this a little bit. > > > > // Parameters > num_points=500; > initial_diameter = 200; // base diameter > height = 75; // Total height (3 rounds × 25mm per round) > diameter_decrease = 25; // 25mm decrease per round > num_holes = 120; > spiral_thickness = 10; // Thickness of the spiral path > hole_diameter = 3; // 3mm holes > > > // Function to calculate points along the spiral > function spiral_points(steps) = [ > for(i = [0:steps-1]) > let( > angle = i * 360 * 5 / steps, // 5 complete rotations > radius = (initial_diameter - (angle/360) * diameter_decrease) / 2, > z = (height * angle) / (360 * 5) > ) > [ > radius * cos(angle), > radius * sin(angle), > z > ] > ]; > > // Function to create points for a hole at a given position and normal > function rotate_points(points, normal, center) = > let( > angle = atan2(normal[1], normal[0]), > elevation = atan2(normal[2], sqrt(normal[0] * normal[0] + > normal[1] * normal[1])) > ) > [ > for(p = points) > let( > rotated = > [[1, 0, 0], [0, cos(elevation), -sin(elevation)], [0, > sin(elevation), cos(elevation)]] * > [[cos(angle), -sin(angle), 0], [sin(angle), cos(angle), > 0], [0, 0, 1]] * > p > ) > [ > rotated[0] + center[0], > rotated[1] + center[1], > rotated[2] + center[2] > ] > ]; > > // Create the main spiral > module spiral() { > points = spiral_points(num_points); // Generate 500 points along the > spiral > > // Create the spiral path > for(i = [0:len(points)-2]) { > hull() { > translate(points[i]) > sphere(d=spiral_thickness, $fn=20); > translate(points[i+1]) > sphere(d=spiral_thickness, $fn=20); > } > } > } > > // Create holes along the spiral > module holes() { > points = spiral_points(num_holes); > > for(i = [0:len(points)-2]) { > // Calculate direction vector for hole orientation > vector = points[i+1] - points[i]; > length = norm(vector); > normal = vector / length; > > // Create hole > translate(points[i]) { > // Create a cylinder oriented along the normal vector > hole_points = rotate_points( > [for(z = [-15:15]) [0, 0, z]], > normal, > [0, 0, 0] > ); > > hull() { > for(p = hole_points) { > translate(p) > sphere(d=hole_diameter, $fn=16); > } > } > } > } > } > > // Final model > difference() { > spiral(); > holes(); > } > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
TO
Trevor Orr
Sun, Jan 12, 2025 10:00 PM

I tried cube() and it was close and probably rotating it like you mentioned would fix it.

On Sunday, January 12, 2025 at 01:55:07 PM PST, Dan Perry via Discuss <discuss@lists.openscad.org> wrote:  

I didn't try out your code, but it looks like you should replace sphere() twice in module spiral() with cube().  To be closer to a perfect flat bar, you would need to x-rotate (or possibly y-rotate) the cube() by the value of angle in module spiral_points().Dan

On Sun, Jan 12, 2025 at 9:34 PM Trevor Orr via Discuss discuss@lists.openscad.org wrote:

I used an AI system to create this, it is for the most part exactly what I what but instead of it being a sphere going around and up I want it to be a flat bar the same size as the sphere.  Any easy way of doing this?
Here is the code it generated, I modified this a little bit.

// Parametersnum_points=500;initial_diameter = 200;  // base diameterheight = 75;  // Total height (3 rounds × 25mm per round)diameter_decrease = 25;  // 25mm decrease per roundnum_holes = 120;spiral_thickness = 10;  // Thickness of the spiral pathhole_diameter = 3;  // 3mm holes

// Function to calculate points along the spiralfunction spiral_points(steps) = [    for(i = [0:steps-1])    let(        angle = i * 360 * 5 / steps,  // 5 complete rotations        radius = (initial_diameter - (angle/360) * diameter_decrease) / 2,        z = (height * angle) / (360 * 5)    )    [        radius * cos(angle),        radius * sin(angle),        z    ]];
// Function to create points for a hole at a given position and normalfunction rotate_points(points, normal, center) =    let(        angle = atan2(normal[1], normal[0]),        elevation = atan2(normal[2], sqrt(normal[0] * normal[0] + normal[1] * normal[1]))    )    [        for(p = points)        let(            rotated =                 [[1, 0, 0], [0, cos(elevation), -sin(elevation)], [0, sin(elevation), cos(elevation)]] *                [[cos(angle), -sin(angle), 0], [sin(angle), cos(angle), 0], [0, 0, 1]] *                p        )        [            rotated[0] + center[0],            rotated[1] + center[1],            rotated[2] + center[2]        ]    ];
// Create the main spiralmodule spiral() {    points = spiral_points(num_points);  // Generate 500 points along the spiral        // Create the spiral path    for(i = [0:len(points)-2]) {        hull() {            translate(points[i])                sphere(d=spiral_thickness, $fn=20);            translate(points[i+1])                sphere(d=spiral_thickness, $fn=20);        }    }}
// Create holes along the spiralmodule holes() {    points = spiral_points(num_holes);        for(i = [0:len(points)-2]) {        // Calculate direction vector for hole orientation        vector = points[i+1] - points[i];        length = norm(vector);        normal = vector / length;                // Create hole        translate(points[i]) {            // Create a cylinder oriented along the normal vector            hole_points = rotate_points(                [for(z = [-15:15]) [0, 0, z]],                normal,                [0, 0, 0]            );                        hull() {                for(p = hole_points) {                    translate(p)                        sphere(d=hole_diameter, $fn=16);                }            }        }    }}
// Final modeldifference() {    spiral();    holes();}


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I tried cube() and it was close and probably rotating it like you mentioned would fix it. On Sunday, January 12, 2025 at 01:55:07 PM PST, Dan Perry via Discuss <discuss@lists.openscad.org> wrote: I didn't try out your code, but it looks like you should replace sphere() twice in module spiral() with cube().  To be closer to a perfect flat bar, you would need to x-rotate (or possibly y-rotate) the cube() by the value of angle in module spiral_points().Dan On Sun, Jan 12, 2025 at 9:34 PM Trevor Orr via Discuss <discuss@lists.openscad.org> wrote: I used an AI system to create this, it is for the most part exactly what I what but instead of it being a sphere going around and up I want it to be a flat bar the same size as the sphere.  Any easy way of doing this? Here is the code it generated, I modified this a little bit. // Parametersnum_points=500;initial_diameter = 200;  // base diameterheight = 75;  // Total height (3 rounds × 25mm per round)diameter_decrease = 25;  // 25mm decrease per roundnum_holes = 120;spiral_thickness = 10;  // Thickness of the spiral pathhole_diameter = 3;  // 3mm holes // Function to calculate points along the spiralfunction spiral_points(steps) = [    for(i = [0:steps-1])    let(        angle = i * 360 * 5 / steps,  // 5 complete rotations        radius = (initial_diameter - (angle/360) * diameter_decrease) / 2,        z = (height * angle) / (360 * 5)    )    [        radius * cos(angle),        radius * sin(angle),        z    ]]; // Function to create points for a hole at a given position and normalfunction rotate_points(points, normal, center) =    let(        angle = atan2(normal[1], normal[0]),        elevation = atan2(normal[2], sqrt(normal[0] * normal[0] + normal[1] * normal[1]))    )    [        for(p = points)        let(            rotated =                 [[1, 0, 0], [0, cos(elevation), -sin(elevation)], [0, sin(elevation), cos(elevation)]] *                [[cos(angle), -sin(angle), 0], [sin(angle), cos(angle), 0], [0, 0, 1]] *                p        )        [            rotated[0] + center[0],            rotated[1] + center[1],            rotated[2] + center[2]        ]    ]; // Create the main spiralmodule spiral() {    points = spiral_points(num_points);  // Generate 500 points along the spiral        // Create the spiral path    for(i = [0:len(points)-2]) {        hull() {            translate(points[i])                sphere(d=spiral_thickness, $fn=20);            translate(points[i+1])                sphere(d=spiral_thickness, $fn=20);        }    }} // Create holes along the spiralmodule holes() {    points = spiral_points(num_holes);        for(i = [0:len(points)-2]) {        // Calculate direction vector for hole orientation        vector = points[i+1] - points[i];        length = norm(vector);        normal = vector / length;                // Create hole        translate(points[i]) {            // Create a cylinder oriented along the normal vector            hole_points = rotate_points(                [for(z = [-15:15]) [0, 0, z]],                normal,                [0, 0, 0]            );                        hull() {                for(p = hole_points) {                    translate(p)                        sphere(d=hole_diameter, $fn=16);                }            }        }    }} // Final modeldifference() {    spiral();    holes();} _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org
RW
Raymond West
Sun, Jan 12, 2025 10:15 PM

My first thought it to change the two spheres to cube(5,true), in module
spiral, which sort of works, if it a rectangular cross section that you
want for the 'wire' instead of round. but there are oddities with the
smoothness of the spiral curve. I haven't looked into it further.

On 12/01/2025 21:34, Trevor Orr via Discuss wrote:

I used an AI system to create this, it is for the most part exactly
what I what but instead of it being a sphere going around and up I
want it to be a flat bar the same size as the sphere.  Any easy way of
doing this?

Here is the code it generated, I modified this a little bit.

// Parameters
num_points=500;
initial_diameter = 200;  // base diameter
height = 75;  // Total height (3 rounds × 25mm per round)
diameter_decrease = 25;  // 25mm decrease per round
num_holes = 120;
spiral_thickness = 10;  // Thickness of the spiral path
hole_diameter = 3;  // 3mm holes

// Function to calculate points along the spiral
function spiral_points(steps) = [
    for(i = [0:steps-1])
    let(
        angle = i * 360 * 5 / steps,  // 5 complete rotations
        radius = (initial_diameter - (angle/360) * diameter_decrease) / 2,
        z = (height * angle) / (360 * 5)
    )
    [
        radius * cos(angle),
        radius * sin(angle),
        z
    ]
];

// Function to create points for a hole at a given position and normal
function rotate_points(points, normal, center) =
    let(
        angle = atan2(normal[1], normal[0]),
        elevation = atan2(normal[2], sqrt(normal[0] * normal[0] +
normal[1] * normal[1]))
    )
    [
        for(p = points)
        let(
            rotated =
                [[1, 0, 0], [0, cos(elevation), -sin(elevation)], [0,
sin(elevation), cos(elevation)]] *
                [[cos(angle), -sin(angle), 0], [sin(angle),
cos(angle), 0], [0, 0, 1]] *
                p
        )
        [
            rotated[0] + center[0],
            rotated[1] + center[1],
            rotated[2] + center[2]
        ]
    ];

// Create the main spiral
module spiral() {
    points = spiral_points(num_points);  // Generate 500 points along
the spiral
    // Create the spiral path
    for(i = [0:len(points)-2]) {
        hull() {
            translate(points[i])
                sphere(d=spiral_thickness, $fn=20);
            translate(points[i+1])
                sphere(d=spiral_thickness, $fn=20);
        }
    }
}

// Create holes along the spiral
module holes() {
    points = spiral_points(num_holes);
    for(i = [0:len(points)-2]) {
        // Calculate direction vector for hole orientation
        vector = points[i+1] - points[i];
        length = norm(vector);
        normal = vector / length;
        // Create hole
        translate(points[i]) {
            // Create a cylinder oriented along the normal vector
            hole_points = rotate_points(
                [for(z = [-15:15]) [0, 0, z]],
                normal,
                [0, 0, 0]
            );
            hull() {
                for(p = hole_points) {
                    translate(p)
                        sphere(d=hole_diameter, $fn=16);
                }
            }
        }
    }
}

// Final model
difference() {
    spiral();
    holes();
}


OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org

My first thought it to change the two spheres to cube(5,true), in module spiral, which sort of works, if it a rectangular cross section that you want for the 'wire' instead of round. but there are oddities with the smoothness of the spiral curve. I haven't looked into it further. On 12/01/2025 21:34, Trevor Orr via Discuss wrote: > I used an AI system to create this, it is for the most part exactly > what I what but instead of it being a sphere going around and up I > want it to be a flat bar the same size as the sphere.  Any easy way of > doing this? > > Here is the code it generated, I modified this a little bit. > > > > // Parameters > num_points=500; > initial_diameter = 200;  // base diameter > height = 75;  // Total height (3 rounds × 25mm per round) > diameter_decrease = 25;  // 25mm decrease per round > num_holes = 120; > spiral_thickness = 10;  // Thickness of the spiral path > hole_diameter = 3;  // 3mm holes > > > // Function to calculate points along the spiral > function spiral_points(steps) = [ >     for(i = [0:steps-1]) >     let( >         angle = i * 360 * 5 / steps,  // 5 complete rotations >         radius = (initial_diameter - (angle/360) * diameter_decrease) / 2, >         z = (height * angle) / (360 * 5) >     ) >     [ >         radius * cos(angle), >         radius * sin(angle), >         z >     ] > ]; > > // Function to create points for a hole at a given position and normal > function rotate_points(points, normal, center) = >     let( >         angle = atan2(normal[1], normal[0]), >         elevation = atan2(normal[2], sqrt(normal[0] * normal[0] + > normal[1] * normal[1])) >     ) >     [ >         for(p = points) >         let( >             rotated = >                 [[1, 0, 0], [0, cos(elevation), -sin(elevation)], [0, > sin(elevation), cos(elevation)]] * >                 [[cos(angle), -sin(angle), 0], [sin(angle), > cos(angle), 0], [0, 0, 1]] * >                 p >         ) >         [ >             rotated[0] + center[0], >             rotated[1] + center[1], >             rotated[2] + center[2] >         ] >     ]; > > // Create the main spiral > module spiral() { >     points = spiral_points(num_points);  // Generate 500 points along > the spiral >     // Create the spiral path >     for(i = [0:len(points)-2]) { >         hull() { >             translate(points[i]) >                 sphere(d=spiral_thickness, $fn=20); >             translate(points[i+1]) >                 sphere(d=spiral_thickness, $fn=20); >         } >     } > } > > // Create holes along the spiral > module holes() { >     points = spiral_points(num_holes); >     for(i = [0:len(points)-2]) { >         // Calculate direction vector for hole orientation >         vector = points[i+1] - points[i]; >         length = norm(vector); >         normal = vector / length; >         // Create hole >         translate(points[i]) { >             // Create a cylinder oriented along the normal vector >             hole_points = rotate_points( >                 [for(z = [-15:15]) [0, 0, z]], >                 normal, >                 [0, 0, 0] >             ); >             hull() { >                 for(p = hole_points) { >                     translate(p) >                         sphere(d=hole_diameter, $fn=16); >                 } >             } >         } >     } > } > > // Final model > difference() { >     spiral(); >     holes(); > } > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org
TO
Trevor Orr
Sun, Jan 12, 2025 10:27 PM

Rotating the cube was the trick to make it work I had to rotate it on the Z axis.  Doing that somehow messed up the hole placement so I will have to fix that part now.

// Create the main spiralmodule spiral() {    points = spiral_points(num_points);  // Generate 500 points along the spiral        // Create the spiral path    for(i = [0:len(points)-2]) { angle = i * 360 * 5 / len(points);        hull() {            translate(points[i])                //sphere(d=spiral_thickness, $fn=20); rotate([0, 0, angle]) cube([spiral_thickness, 1, spiral_thickness]);            translate(points[i+1])                //sphere(d=spiral_thickness, $fn=20); rotate([0, 0, angle]) cube([spiral_thickness, 1, spiral_thickness]);        }    }}

On Sunday, January 12, 2025 at 02:16:06 PM PST, Raymond West via Discuss <discuss@lists.openscad.org> wrote:  

My first thought it to change the two spheres to cube(5,true), in module spiral, which sort of works, if it a rectangular cross section that you want for the 'wire' instead of round. but there are oddities with the smoothness of the spiral curve. I haven't looked into it further.

On 12/01/2025 21:34, Trevor Orr via Discuss wrote:

I used an AI system to create this, it is for the most part exactly what I what but instead of it being a sphere going around and up I want it to be a flat bar the same size as the sphere.  Any easy way of doing this?
Here is the code it generated, I modified this a little bit.

// Parameters num_points=500; initial_diameter = 200;  // base diameter height = 75;  // Total height (3 rounds × 25mm per round) diameter_decrease = 25;  // 25mm decrease per round num_holes = 120; spiral_thickness = 10;  // Thickness of the spiral path hole_diameter = 3;  // 3mm holes 

// Function to calculate points along the spiral function spiral_points(steps) = [     for(i = [0:steps-1])     let(         angle = i * 360 * 5 / steps,  // 5 complete rotations         radius = (initial_diameter - (angle/360) * diameter_decrease) / 2,         z = (height * angle) / (360 * 5)     )     [         radius * cos(angle),         radius * sin(angle),         z     ] ];
// Function to create points for a hole at a given position and normal function rotate_points(points, normal, center) =     let(         angle = atan2(normal[1], normal[0]),         elevation = atan2(normal[2], sqrt(normal[0] * normal[0] + normal[1] * normal[1]))     )     [         for(p = points)         let(             rotated =                  [[1, 0, 0], [0, cos(elevation), -sin(elevation)], [0, sin(elevation), cos(elevation)]] *                 [[cos(angle), -sin(angle), 0], [sin(angle), cos(angle), 0], [0, 0, 1]] *                 p         )         [             rotated[0] + center[0],             rotated[1] + center[1],             rotated[2] + center[2]         ]     ];
// Create the main spiral module spiral() {     points = spiral_points(num_points);  // Generate 500 points along the spiral          // Create the spiral path     for(i = [0:len(points)-2]) {         hull() {             translate(points[i])                 sphere(d=spiral_thickness, $fn=20);             translate(points[i+1])                 sphere(d=spiral_thickness, $fn=20);         }     } }
// Create holes along the spiral module holes() {     points = spiral_points(num_holes);          for(i = [0:len(points)-2]) {         // Calculate direction vector for hole orientation         vector = points[i+1] - points[i];         length = norm(vector);         normal = vector / length;                  // Create hole         translate(points[i]) {             // Create a cylinder oriented along the normal vector             hole_points = rotate_points(                 [for(z = [-15:15]) [0, 0, z]],                 normal,                 [0, 0, 0]             );                          hull() {                 for(p = hole_points) {                     translate(p)                         sphere(d=hole_diameter, $fn=16);                 }             }         }     } }
// Final model difference() {     spiral();     holes(); }


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Rotating the cube was the trick to make it work I had to rotate it on the Z axis.  Doing that somehow messed up the hole placement so I will have to fix that part now. // Create the main spiralmodule spiral() {    points = spiral_points(num_points);  // Generate 500 points along the spiral        // Create the spiral path    for(i = [0:len(points)-2]) { angle = i * 360 * 5 / len(points);        hull() {            translate(points[i])                //sphere(d=spiral_thickness, $fn=20); rotate([0, 0, angle]) cube([spiral_thickness, 1, spiral_thickness]);            translate(points[i+1])                //sphere(d=spiral_thickness, $fn=20); rotate([0, 0, angle]) cube([spiral_thickness, 1, spiral_thickness]);        }    }} On Sunday, January 12, 2025 at 02:16:06 PM PST, Raymond West via Discuss <discuss@lists.openscad.org> wrote: My first thought it to change the two spheres to cube(5,true), in module spiral, which sort of works, if it a rectangular cross section that you want for the 'wire' instead of round. but there are oddities with the smoothness of the spiral curve. I haven't looked into it further. On 12/01/2025 21:34, Trevor Orr via Discuss wrote: I used an AI system to create this, it is for the most part exactly what I what but instead of it being a sphere going around and up I want it to be a flat bar the same size as the sphere.  Any easy way of doing this? Here is the code it generated, I modified this a little bit. // Parameters num_points=500; initial_diameter = 200;  // base diameter height = 75;  // Total height (3 rounds × 25mm per round) diameter_decrease = 25;  // 25mm decrease per round num_holes = 120; spiral_thickness = 10;  // Thickness of the spiral path hole_diameter = 3;  // 3mm holes // Function to calculate points along the spiral function spiral_points(steps) = [     for(i = [0:steps-1])     let(         angle = i * 360 * 5 / steps,  // 5 complete rotations         radius = (initial_diameter - (angle/360) * diameter_decrease) / 2,         z = (height * angle) / (360 * 5)     )     [         radius * cos(angle),         radius * sin(angle),         z     ] ]; // Function to create points for a hole at a given position and normal function rotate_points(points, normal, center) =     let(         angle = atan2(normal[1], normal[0]),         elevation = atan2(normal[2], sqrt(normal[0] * normal[0] + normal[1] * normal[1]))     )     [         for(p = points)         let(             rotated =                  [[1, 0, 0], [0, cos(elevation), -sin(elevation)], [0, sin(elevation), cos(elevation)]] *                 [[cos(angle), -sin(angle), 0], [sin(angle), cos(angle), 0], [0, 0, 1]] *                 p         )         [             rotated[0] + center[0],             rotated[1] + center[1],             rotated[2] + center[2]         ]     ]; // Create the main spiral module spiral() {     points = spiral_points(num_points);  // Generate 500 points along the spiral          // Create the spiral path     for(i = [0:len(points)-2]) {         hull() {             translate(points[i])                 sphere(d=spiral_thickness, $fn=20);             translate(points[i+1])                 sphere(d=spiral_thickness, $fn=20);         }     } } // Create holes along the spiral module holes() {     points = spiral_points(num_holes);          for(i = [0:len(points)-2]) {         // Calculate direction vector for hole orientation         vector = points[i+1] - points[i];         length = norm(vector);         normal = vector / length;                  // Create hole         translate(points[i]) {             // Create a cylinder oriented along the normal vector             hole_points = rotate_points(                 [for(z = [-15:15]) [0, 0, z]],                 normal,                 [0, 0, 0]             );                          hull() {                 for(p = hole_points) {                     translate(p)                         sphere(d=hole_diameter, $fn=16);                 }             }         }     } } // Final model difference() {     spiral();     holes(); } _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org
RW
Raymond West
Sun, Jan 12, 2025 10:54 PM

My method for drawing springs, threads, and similar spirals, is to make
a profile in 2d, extrude it, say 0.5mm, then rotate it, and translate it
in x, the overall radius, then within in a  for loop, rotate it and
translate in z a small amount. The hull will smooth it out, but I've
never bothered  with that. As this 'spring' is tapered, then also alter
the translate value  within the loop.

On 12/01/2025 22:27, Trevor Orr via Discuss wrote:

Rotating the cube was the trick to make it work I had to rotate it on
the Z axis.  Doing that somehow messed up the hole placement so I will
have to fix that part now.

// Create the main spiral
module spiral() {
    points = spiral_points(num_points);  // Generate 500 points along
the spiral
    // Create the spiral path
    for(i = [0:len(points)-2]) {
angle = i * 360 * 5 / len(points);
        hull() {
            translate(points[i])
                //sphere(d=spiral_thickness, $fn=20);
rotate([0, 0, angle])
cube([spiral_thickness, 1, spiral_thickness]);
            translate(points[i+1])
                //sphere(d=spiral_thickness, $fn=20);
rotate([0, 0, angle])
cube([spiral_thickness, 1, spiral_thickness]);
        }
    }
}

On Sunday, January 12, 2025 at 02:16:06 PM PST, Raymond West via
Discuss discuss@lists.openscad.org wrote:

My first thought it to change the two spheres to cube(5,true), in
module spiral, which sort of works, if it a rectangular cross section
that you want for the 'wire' instead of round. but there are oddities
with the smoothness of the spiral curve. I haven't looked into it further.

On 12/01/2025 21:34, Trevor Orr via Discuss wrote:
I used an AI system to create this, it is for the most part exactly
what I what but instead of it being a sphere going around and up I
want it to be a flat bar the same size as the sphere.  Any easy way of
doing this?

Here is the code it generated, I modified this a little bit.

// Parameters
num_points=500;
initial_diameter = 200;  // base diameter
height = 75;  // Total height (3 rounds × 25mm per round)
diameter_decrease = 25;  // 25mm decrease per round
num_holes = 120;
spiral_thickness = 10;  // Thickness of the spiral path
hole_diameter = 3;  // 3mm holes

// Function to calculate points along the spiral
function spiral_points(steps) = [
    for(i = [0:steps-1])
    let(
        angle = i * 360 * 5 / steps,  // 5 complete rotations
        radius = (initial_diameter - (angle/360) * diameter_decrease) / 2,
        z = (height * angle) / (360 * 5)
    )
    [
        radius * cos(angle),
        radius * sin(angle),
        z
    ]
];

// Function to create points for a hole at a given position and normal
function rotate_points(points, normal, center) =
    let(
        angle = atan2(normal[1], normal[0]),
        elevation = atan2(normal[2], sqrt(normal[0] * normal[0] +
normal[1] * normal[1]))
    )
    [
        for(p = points)
        let(
            rotated =
                [[1, 0, 0], [0, cos(elevation), -sin(elevation)], [0,
sin(elevation), cos(elevation)]] *
                [[cos(angle), -sin(angle), 0], [sin(angle),
cos(angle), 0], [0, 0, 1]] *
                p
        )
        [
            rotated[0] + center[0],
            rotated[1] + center[1],
            rotated[2] + center[2]
        ]
    ];

// Create the main spiral
module spiral() {
    points = spiral_points(num_points);  // Generate 500 points along
the spiral
    // Create the spiral path
    for(i = [0:len(points)-2]) {
        hull() {
            translate(points[i])
                sphere(d=spiral_thickness, $fn=20);
            translate(points[i+1])
                sphere(d=spiral_thickness, $fn=20);
        }
    }
}

// Create holes along the spiral
module holes() {
    points = spiral_points(num_holes);
    for(i = [0:len(points)-2]) {
        // Calculate direction vector for hole orientation
        vector = points[i+1] - points[i];
        length = norm(vector);
        normal = vector / length;
        // Create hole
        translate(points[i]) {
            // Create a cylinder oriented along the normal vector
            hole_points = rotate_points(
                [for(z = [-15:15]) [0, 0, z]],
                normal,
                [0, 0, 0]
            );
            hull() {
                for(p = hole_points) {
                    translate(p)
sphere(d=hole_diameter, $fn=16);
                }
            }
        }
    }
}

// Final model
difference() {
    spiral();
    holes();
}


OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org mailto:discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org

My method for drawing springs, threads, and similar spirals, is to make a profile in 2d, extrude it, say 0.5mm, then rotate it, and translate it in x, the overall radius, then within in a  for loop, rotate it and translate in z a small amount. The hull will smooth it out, but I've never bothered  with that. As this 'spring' is tapered, then also alter the translate value  within the loop. On 12/01/2025 22:27, Trevor Orr via Discuss wrote: > Rotating the cube was the trick to make it work I had to rotate it on > the Z axis.  Doing that somehow messed up the hole placement so I will > have to fix that part now. > > > // Create the main spiral > module spiral() { >     points = spiral_points(num_points);  // Generate 500 points along > the spiral >     // Create the spiral path >     for(i = [0:len(points)-2]) { > angle = i * 360 * 5 / len(points); >         hull() { >             translate(points[i]) >                 //sphere(d=spiral_thickness, $fn=20); > rotate([0, 0, angle]) > cube([spiral_thickness, 1, spiral_thickness]); >             translate(points[i+1]) >                 //sphere(d=spiral_thickness, $fn=20); > rotate([0, 0, angle]) > cube([spiral_thickness, 1, spiral_thickness]); >         } >     } > } > > > > > > > > On Sunday, January 12, 2025 at 02:16:06 PM PST, Raymond West via > Discuss <discuss@lists.openscad.org> wrote: > > > My first thought it to change the two spheres to cube(5,true), in > module spiral, which sort of works, if it a rectangular cross section > that you want for the 'wire' instead of round. but there are oddities > with the smoothness of the spiral curve. I haven't looked into it further. > > On 12/01/2025 21:34, Trevor Orr via Discuss wrote: > I used an AI system to create this, it is for the most part exactly > what I what but instead of it being a sphere going around and up I > want it to be a flat bar the same size as the sphere.  Any easy way of > doing this? > > Here is the code it generated, I modified this a little bit. > > > > // Parameters > num_points=500; > initial_diameter = 200;  // base diameter > height = 75;  // Total height (3 rounds × 25mm per round) > diameter_decrease = 25;  // 25mm decrease per round > num_holes = 120; > spiral_thickness = 10;  // Thickness of the spiral path > hole_diameter = 3;  // 3mm holes > > > // Function to calculate points along the spiral > function spiral_points(steps) = [ >     for(i = [0:steps-1]) >     let( >         angle = i * 360 * 5 / steps,  // 5 complete rotations >         radius = (initial_diameter - (angle/360) * diameter_decrease) / 2, >         z = (height * angle) / (360 * 5) >     ) >     [ >         radius * cos(angle), >         radius * sin(angle), >         z >     ] > ]; > > // Function to create points for a hole at a given position and normal > function rotate_points(points, normal, center) = >     let( >         angle = atan2(normal[1], normal[0]), >         elevation = atan2(normal[2], sqrt(normal[0] * normal[0] + > normal[1] * normal[1])) >     ) >     [ >         for(p = points) >         let( >             rotated = >                 [[1, 0, 0], [0, cos(elevation), -sin(elevation)], [0, > sin(elevation), cos(elevation)]] * >                 [[cos(angle), -sin(angle), 0], [sin(angle), > cos(angle), 0], [0, 0, 1]] * >                 p >         ) >         [ >             rotated[0] + center[0], >             rotated[1] + center[1], >             rotated[2] + center[2] >         ] >     ]; > > // Create the main spiral > module spiral() { >     points = spiral_points(num_points);  // Generate 500 points along > the spiral >     // Create the spiral path >     for(i = [0:len(points)-2]) { >         hull() { >             translate(points[i]) >                 sphere(d=spiral_thickness, $fn=20); >             translate(points[i+1]) >                 sphere(d=spiral_thickness, $fn=20); >         } >     } > } > > // Create holes along the spiral > module holes() { >     points = spiral_points(num_holes); >     for(i = [0:len(points)-2]) { >         // Calculate direction vector for hole orientation >         vector = points[i+1] - points[i]; >         length = norm(vector); >         normal = vector / length; >         // Create hole >         translate(points[i]) { >             // Create a cylinder oriented along the normal vector >             hole_points = rotate_points( >                 [for(z = [-15:15]) [0, 0, z]], >                 normal, >                 [0, 0, 0] >             ); >             hull() { >                 for(p = hole_points) { >                     translate(p) > sphere(d=hole_diameter, $fn=16); >                 } >             } >         } >     } > } > > // Final model > difference() { >     spiral(); >     holes(); > } > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org
TO
Trevor Orr
Sun, Jan 12, 2025 11:07 PM

That sounds to like it would work better because I could put the holes in
it before the extrude.

On January 12, 2025 2:54:59 PM Raymond West via Discuss
discuss@lists.openscad.org wrote:

My method for drawing springs, threads, and similar spirals, is to make a
profile in 2d, extrude it, say 0.5mm, then rotate it, and translate it in
x, the overall radius, then within in a  for loop, rotate it and translate
in z a small amount. The hull will smooth it out, but I've never bothered
with that. As this 'spring' is tapered, then also alter the translate value
within the loop.

On 12/01/2025 22:27, Trevor Orr via Discuss wrote:

Rotating the cube was the trick to make it work I had to rotate it on the Z
axis.  Doing that somehow messed up the hole placement so I will have to
fix that part now.

// Create the main spiral
module spiral() {
points = spiral_points(num_points);  // Generate 500 points along the spiral

// Create the spiral path
for(i = [0:len(points)-2]) {

angle = i * 360 * 5 / len(points);
hull() {
translate(points[i])
//sphere(d=spiral_thickness, $fn=20);
rotate([0, 0, angle])
cube([spiral_thickness, 1, spiral_thickness]);
translate(points[i+1])
//sphere(d=spiral_thickness, $fn=20);
rotate([0, 0, angle])
cube([spiral_thickness, 1, spiral_thickness]);
}
}
}

On Sunday, January 12, 2025 at 02:16:06 PM PST, Raymond West via Discuss
discuss@lists.openscad.org wrote:

My first thought it to change the two spheres to cube(5,true), in module
spiral, which sort of works, if it a rectangular cross section that you
want for the 'wire' instead of round. but there are oddities with the
smoothness of the spiral curve. I haven't looked into it further.
On 12/01/2025 21:34, Trevor Orr via Discuss wrote:

I used an AI system to create this, it is for the most part exactly what I
what but instead of it being a sphere going around and up I want it to be a
flat bar the same size as the sphere.  Any easy way of doing this?

Here is the code it generated, I modified this a little bit.

// Parameters
num_points=500;
initial_diameter = 200;  // base diameter
height = 75;  // Total height (3 rounds × 25mm per round)
diameter_decrease = 25;  // 25mm decrease per round
num_holes = 120;
spiral_thickness = 10;  // Thickness of the spiral path
hole_diameter = 3;  // 3mm holes

// Function to calculate points along the spiral
function spiral_points(steps) = [
for(i = [0:steps-1])
let(
angle = i * 360 * 5 / steps,  // 5 complete rotations
radius = (initial_diameter - (angle/360) * diameter_decrease) / 2,
z = (height * angle) / (360 * 5)
)
[
radius * cos(angle),
radius * sin(angle),
z
]
];

// Function to create points for a hole at a given position and normal
function rotate_points(points, normal, center) =
let(
angle = atan2(normal[1], normal[0]),
elevation = atan2(normal[2], sqrt(normal[0] * normal[0] + normal[1] *
normal[1]))
)
[
for(p = points)
let(
rotated =
[[1, 0, 0], [0, cos(elevation), -sin(elevation)], [0, sin(elevation),
cos(elevation)]] *
[[cos(angle), -sin(angle), 0], [sin(angle), cos(angle), 0], [0, 0, 1]] *
p
)
[
rotated[0] + center[0],
rotated[1] + center[1],
rotated[2] + center[2]
]
];

// Create the main spiral
module spiral() {
points = spiral_points(num_points);  // Generate 500 points along the spiral

// Create the spiral path
for(i = [0:len(points)-2]) {
    hull() {
        translate(points[i])
            sphere(d=spiral_thickness, $fn=20);
        translate(points[i+1])
            sphere(d=spiral_thickness, $fn=20);
    }
}

}

// Create holes along the spiral
module holes() {
points = spiral_points(num_holes);

for(i = [0:len(points)-2]) {
    // Calculate direction vector for hole orientation
    vector = points[i+1] - points[i];
    length = norm(vector);
    normal = vector / length;

    // Create hole
    translate(points[i]) {
        // Create a cylinder oriented along the normal vector
        hole_points = rotate_points(
            [for(z = [-15:15]) [0, 0, z]],
            normal,
            [0, 0, 0]
        );

        hull() {
            for(p = hole_points) {
                translate(p)
                    sphere(d=hole_diameter, $fn=16);
            }
        }
    }
}

}

// Final model
difference() {
spiral();
holes();
}


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

That sounds to like it would work better because I could put the holes in it before the extrude. On January 12, 2025 2:54:59 PM Raymond West via Discuss <discuss@lists.openscad.org> wrote: > My method for drawing springs, threads, and similar spirals, is to make a > profile in 2d, extrude it, say 0.5mm, then rotate it, and translate it in > x, the overall radius, then within in a for loop, rotate it and translate > in z a small amount. The hull will smooth it out, but I've never bothered > with that. As this 'spring' is tapered, then also alter the translate value > within the loop. > > On 12/01/2025 22:27, Trevor Orr via Discuss wrote: >> Rotating the cube was the trick to make it work I had to rotate it on the Z >> axis. Doing that somehow messed up the hole placement so I will have to >> fix that part now. >> >> >> >> >> // Create the main spiral >> module spiral() { >> points = spiral_points(num_points); // Generate 500 points along the spiral >> >> // Create the spiral path >> for(i = [0:len(points)-2]) { >> angle = i * 360 * 5 / len(points); >> hull() { >> translate(points[i]) >> //sphere(d=spiral_thickness, $fn=20); >> rotate([0, 0, angle]) >> cube([spiral_thickness, 1, spiral_thickness]); >> translate(points[i+1]) >> //sphere(d=spiral_thickness, $fn=20); >> rotate([0, 0, angle]) >> cube([spiral_thickness, 1, spiral_thickness]); >> } >> } >> } >> >> >> >> >> >> >> >> >> >> >> >> >> On Sunday, January 12, 2025 at 02:16:06 PM PST, Raymond West via Discuss >> <discuss@lists.openscad.org> wrote: >> >> >> My first thought it to change the two spheres to cube(5,true), in module >> spiral, which sort of works, if it a rectangular cross section that you >> want for the 'wire' instead of round. but there are oddities with the >> smoothness of the spiral curve. I haven't looked into it further. >> On 12/01/2025 21:34, Trevor Orr via Discuss wrote: >>> >> >> I used an AI system to create this, it is for the most part exactly what I >> what but instead of it being a sphere going around and up I want it to be a >> flat bar the same size as the sphere. Any easy way of doing this? >> >> >> Here is the code it generated, I modified this a little bit. >> >> >> >> >> >> >> // Parameters >> num_points=500; >> initial_diameter = 200; // base diameter >> height = 75; // Total height (3 rounds × 25mm per round) >> diameter_decrease = 25; // 25mm decrease per round >> num_holes = 120; >> spiral_thickness = 10; // Thickness of the spiral path >> hole_diameter = 3; // 3mm holes >> >> >> >> >> // Function to calculate points along the spiral >> function spiral_points(steps) = [ >> for(i = [0:steps-1]) >> let( >> angle = i * 360 * 5 / steps, // 5 complete rotations >> radius = (initial_diameter - (angle/360) * diameter_decrease) / 2, >> z = (height * angle) / (360 * 5) >> ) >> [ >> radius * cos(angle), >> radius * sin(angle), >> z >> ] >> ]; >> >> >> // Function to create points for a hole at a given position and normal >> function rotate_points(points, normal, center) = >> let( >> angle = atan2(normal[1], normal[0]), >> elevation = atan2(normal[2], sqrt(normal[0] * normal[0] + normal[1] * >> normal[1])) >> ) >> [ >> for(p = points) >> let( >> rotated = >> [[1, 0, 0], [0, cos(elevation), -sin(elevation)], [0, sin(elevation), >> cos(elevation)]] * >> [[cos(angle), -sin(angle), 0], [sin(angle), cos(angle), 0], [0, 0, 1]] * >> p >> ) >> [ >> rotated[0] + center[0], >> rotated[1] + center[1], >> rotated[2] + center[2] >> ] >> ]; >> >> >> // Create the main spiral >> module spiral() { >> points = spiral_points(num_points); // Generate 500 points along the spiral >> >> // Create the spiral path >> for(i = [0:len(points)-2]) { >> hull() { >> translate(points[i]) >> sphere(d=spiral_thickness, $fn=20); >> translate(points[i+1]) >> sphere(d=spiral_thickness, $fn=20); >> } >> } >> } >> >> >> // Create holes along the spiral >> module holes() { >> points = spiral_points(num_holes); >> >> for(i = [0:len(points)-2]) { >> // Calculate direction vector for hole orientation >> vector = points[i+1] - points[i]; >> length = norm(vector); >> normal = vector / length; >> >> // Create hole >> translate(points[i]) { >> // Create a cylinder oriented along the normal vector >> hole_points = rotate_points( >> [for(z = [-15:15]) [0, 0, z]], >> normal, >> [0, 0, 0] >> ); >> >> hull() { >> for(p = hole_points) { >> translate(p) >> sphere(d=hole_diameter, $fn=16); >> } >> } >> } >> } >> } >> >> >> // Final model >> difference() { >> spiral(); >> holes(); >> } >> >> >> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org