Screw thread - first attempt

68 views
Skip to first unread message

Ian Mercer

unread,
Dec 7, 2020, 2:23:14 AM12/7/20
to IceSL
Wondering if anyone else has attempted to create screw threads using ICESL implicit functions. Here's my first attempt using an implicit_distance_field:




-- conical screw thread

r = 20.5
height = 40

shape = implicit_distance_field( v(-r,-r,0), v(r,r,height),
[[
uniform float base_radius = 12;
uniform float top_radius = 10;
uniform float height = 15;
uniform float th = 0.9;
float distance(vec3 p) 
{
    // thread size ratio
    float fh = p.z / th;

    // conical shape
    float r = base_radius + (top_radius-base_radius) * (p.z/height);

    // fade in the screw thread
    float tr = min(2,
      min(0.2*p.z*p.z, 
        0.2*(height-p.z)*(height-p.z)));

    float cn = sqrt((p.x*p.x)+(p.y*p.y)) - r;

    float drill_hole = 4 - sqrt((p.x*p.x)+(p.y*p.y));

return max(drill_hole, min(cn, sqrt(
     (p.x+tr*cos(fh))*(p.x+tr*cos(fh)) + 
     (p.y+tr*sin(fh))*(p.y+tr*sin(fh))
     ) / (2*r) - 0.51));
}
]])

set_uniform_scalar(shape, 'base_radius', 12.4)
set_uniform_scalar(shape, 'top_radius', 9.2)
set_uniform_scalar(shape, 'height', height)
set_uniform_scalar(shape, 'th', 0.9)

emit(shape, 5)

Re-try WhenDown

unread,
Dec 7, 2020, 5:47:23 AM12/7/20
to IceSL
I see you found the uniform variables yourself, so disregard my last message.

This one looks good! If you wanna contribute this as an example packaged with IceSL, please do a PR it to the following repo:


Le 7 déc. 2020 à 08:23, Ian Mercer <i...@mercerfamily.org> a écrit :

Wondering if anyone else has attempted to create screw threads using ICESL implicit functions. Here's my first attempt using an implicit_distance_field:
--
You received this message because you are subscribed to the Google Groups "IceSL" group.
To unsubscribe from this group and stop receiving emails from it, send an email to icesl+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/icesl/51e6ba04-2a8a-4c57-ad73-5f4c057e9b26n%40googlegroups.com.

MEHULKUMAR DHOLA

unread,
May 14, 2024, 7:01:44 AM5/14/24
to IceSL
I am making parametric spiral bevel gear do you want to work on that project
Reply all
Reply to author
Forward
0 new messages