POV-Ray : Newsgroups : povray.general : Standard machine screw threads, via f_helix1 isosurface Server Time
29 Mar 2024 02:58:25 EDT (-0400)
  Standard machine screw threads, via f_helix1 isosurface (Message 1 to 4 of 4)  
From: Robert Munyer
Subject: Standard machine screw threads, via f_helix1 isosurface
Date: 7 Jun 2019 19:06:48
Message: <875zph8073.fsf@munyer.com>
I figured out how to get f_helix1 to produce the "basic profile" shape
used by standard machine screw threads, both American and metric.

Getting a specific desired shape from f_helix1 is not straightforward,
so I'm posting my code here for the benefit of anyone else who may
want to model this shape.

The scene file below will produce 1/4 inch of #4-40 thread, aligned
with the Y axis, in a scene measured in millimeters.  For a scene
measured in some other unit, change the number 25.4 everywhere it
appears.  For M3-0.5 thread instead of #4-40, change D_maj to 3 and
change Density to 2 (the "0.5" means 2 turns per millimeter).

#version 3.7;
#include "colors.inc"
#include "functions.inc"
#include "textures.inc"
global_settings { assumed_gamma 1 }
object {



#local D_maj = (4 * 13/1000 + 3/50) * 25.4;
#local Density = 40 / 25.4;
#local Y_min = 0 * 25.4;
#local Y_max = 1/4 * 25.4;
#local Max_gradient = 3;

intersection {
  union {
    isosurface {
      function {
        f_helix1 (x, y, - z, 1, Density * 2 * pi, sqrt (3/4) / Density,
                  D_maj / 2 - sqrt (147/256) / Density, sqrt (1/3), 2, 0)
      }
      contained_by {
        box { <- D_maj / 2, Y_min, - D_maj / 2>, <D_maj / 2, Y_max, D_maj / 2> }
      }
      max_gradient Max_gradient
      all_intersections
    }
    cylinder { Y_min * y, Y_max * y, D_maj / 2 - sqrt (75/256) / Density }
  }
  cylinder { Y_min * y, Y_max * y, D_maj / 2 }
}



  texture { Aluminum }
}
plane { y, 0 pigment { color Green } }
light_source { <2, 4, -3> * 25.4 color White }
camera { location <0, 1/8, -3/8> * 25.4 look_at <0, 1/8, 0> * 25.4 }


Post a reply to this message

From: Bald Eagle
Subject: Re: Standard machine screw threads, via f_helix1 isosurface
Date: 8 Jun 2019 10:45:00
Message: <web.5cfbc9adb373d57c4eec112d0@news.povray.org>
Thanks Robert!  :)

I always appreciate some simple detailed scenes that work out some of the
details of shapes that are challenging to quickly figure out from the
documentation.  Often we only have the newsgroups to really give a clear
explanation.

Being short and simple, it makes for a great little scene to dabble with while
having morning coffee.

That said, I've already "broken POV-Ray" and triggered an error I've not yet
seen or even been aware of.

"light source must be defined using new syntax"
No idea when "new" referred to, but this thread is from 2006:
http://news.povray.org/povray.general/thread/%3Cweb.44ae7f55b23eae858b5be8a0@news.povray.org%3E/

Who knew?  I'd sure like more info on that.

So here I am not even through coffee #1, and I've already learned something.  ;)




> The scene file below will produce 1/4 inch of #4-40 thread, aligned
> with the Y axis, in a scene measured in millimeters.  For a scene
> measured in some other unit, change the number 25.4 everywhere it
> appears.  For M3-0.5 thread instead of #4-40, change D_maj to 3 and
> change Density to 2 (the "0.5" means 2 turns per millimeter).

You may want to do something like:
// scene scale
#declare MM = 1;
#declare Inch = 25.4 * MM;
#declare Unit = Inch; // this carries through whole scene

Then you can just (edit|replace) all instances of 25.4 with Unit.
Otherwise you have to hunt for all instances of 25.4, and I always miss at least
ONE  ;)


> #local D_maj = (4 * 13/1000 + 3/50) * 25.4;

13/1000, 3/50 ... These are "magic numbers" - what do they mean?

>         f_helix1 (x, y, - z, 1, Density * 2 * pi, sqrt (3/4) / Density,
>                   D_maj / 2 - sqrt (147/256) / Density, sqrt (1/3), 2, 0)

Same here - sqrt (3/4)?  sqrt (147/256)? :O   sqrt (1/3)?

>     cylinder { Y_min * y, Y_max * y, D_maj / 2 - sqrt (75/256) / Density }

sqrt (75/256)?  :O



 #local Size = 4;  // <--- makes it easier to see what to change
then:
 #local D_maj = (Size * 13/1000 + 3/50) * Unit; // M or # of thread diameter

Rotating screw z*90 makes it easier (for me) to see your thread profile - mostly
due to the reflection of the Aluminum texture.


I don't know what you're using this for (hopefully a larger scene will be
forthcoming ;)  )  but maybe you might consider putting together a little
database of common screw sizes / threads.

Then maybe make a hex nut and difference out the screw.  :)

I'm thinking either use an array, and do something like

ScrewArray [2] = { blah blah isosurface parameters}

#declare M3_05 = 0;
#declare Num4_40 = 1;
and then you can
#declare ScrewType = Num4_40;  // then use this to get ScrewArray [ScrewType]

and other scene  bits can be controlled by
#switch (ScrewType)
     #case (0)
          // M3_05 specific scene stuff here
     #break

     #case (0)
          // M3_05 specific scene stuff here
     #break

     #else
     #debug "Invalid Screw Type specified."
#end


It would be a nice little include file.


Post a reply to this message

From: Robert Munyer
Subject: Re: Standard machine screw threads, via f_helix1 isosurface
Date: 9 Jun 2019 07:40:30
Message: <87blz76l7e.fsf@munyer.com>
Bald Eagle wrote:

>> #local D_maj = (4 * 13/1000 + 3/50) * 25.4;
>
> 13/1000, 3/50 ... These are "magic numbers" - what do they mean?

Those are numbers that were chosen more than 100 years ago, for
reasons that I don't claim to understand, by the people who set
up the gage number system that is still used for smaller American
thread sizes.  You don't need them for larger American sizes nor
for metric sizes.


>>         f_helix1 (x, y, - z, 1, Density * 2 * pi, sqrt (3/4) / Density,
>>                   D_maj / 2 - sqrt (147/256) / Density, sqrt (1/3), 2, 0)
>
> Same here - sqrt (3/4)?  sqrt (147/256)? :O   sqrt (1/3)?

These are also based on numbers that were chosen more than 100
years ago for reasons that I don't claim to understand, but these
have been processed by running the algebra and trigonometry in
f_helix1's source code backward!


> I'm thinking either use an array, and do something like
>
> ScrewArray [2] = { blah blah isosurface parameters}
>
> #declare M3_05 = 0;
> #declare Num4_40 = 1;
> and then you can
> #declare ScrewType = Num4_40;  // then use this to get ScrewArray [ScrewType]

Please note that D_maj and Density are the only values that would
need to be in that array.  Everything else is constant, regardless
of thread size, regardless of American thread vs. metric thread.


> It would be a nice little include file.

I have no plans to produce such an include file, but anyone who
wants to do so should feel free to do so.  I consider the code
that I've posted in this thread to be "public domain" code.


P.S.  It's possible to use "min" and "max" inside the isosurface
function, to replace the "union" and "intersection" outside of it.
I don't know whether this approach would render faster or slower.


Post a reply to this message

From: Mark
Subject: Re: Standard machine screw threads, via f_helix1 isosurface
Date: 11 Sep 2023 08:25:00
Message: <web.64ff068eb373d57cf00fef66b571e5b2@news.povray.org>
Robert Munyer <917### [at] munyercom> wrote:
> I figured out how to get f_helix1 to produce the "basic profile" shape
> used by standard machine screw threads, both American and metric.
>
> Getting a specific desired shape from f_helix1 is not straightforward,
> so I'm posting my code here for the benefit of anyone else who may
> want to model this shape.
>
> The scene file below will produce 1/4 inch of #4-40 thread, aligned
> with the Y axis, in a scene measured in millimeters.  For a scene
> measured in some other unit, change the number 25.4 everywhere it
> appears.  For M3-0.5 thread instead of #4-40, change D_maj to 3 and
> change Density to 2 (the "0.5" means 2 turns per millimeter).
>
> #version 3.7;
> #include "colors.inc"
> #include "functions.inc"
> #include "textures.inc"
> global_settings { assumed_gamma 1 }
> object {
>
>
>
> #local D_maj = (4 * 13/1000 + 3/50) * 25.4;
> #local Density = 40 / 25.4;
> #local Y_min = 0 * 25.4;
> #local Y_max = 1/4 * 25.4;
> #local Max_gradient = 3;
>
> intersection {
>   union {
>     isosurface {
>       function {
>         f_helix1 (x, y, - z, 1, Density * 2 * pi, sqrt (3/4) / Density,
>                   D_maj / 2 - sqrt (147/256) / Density, sqrt (1/3), 2, 0)
>       }
>       contained_by {
>         box { <- D_maj / 2, Y_min, - D_maj / 2>, <D_maj / 2, Y_max, D_maj / 2> }
>       }
>       max_gradient Max_gradient
>       all_intersections
>     }
>     cylinder { Y_min * y, Y_max * y, D_maj / 2 - sqrt (75/256) / Density }
>   }
>   cylinder { Y_min * y, Y_max * y, D_maj / 2 }
> }
>
>
>
>   texture { Aluminum }
> }
> plane { y, 0 pigment { color Green } }
> light_source { <2, 4, -3> * 25.4 color White }
> camera { location <0, 1/8, -3/8> * 25.4 look_at <0, 1/8, 0> * 25.4 }

This is excellent. Thanks.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.