povrayでネジを描画


関数の等値面を使って

以前povrayでネジを書こうと思って、うまく行かずに挫折したことがある。いろいろと調べてみたら、ようやく書き方が分かったので、メモをしておくことにする。ポイントは、等値面を描くisosurfaceと、螺旋を作る関数f_helix1を使うことである。M3のネジを書くソースは以下のような感じになった。

#include "colors.inc"
#include "shapes.inc"
#include "textures.inc"
#include "functions.inc"
#declare Screw=
isosurface {
  function{
    f_helix1(x,y,z,
        1,    // number of helixes, (1 = single helix, 2 = double helix etc.)
        2*2*pi, // For number N of turns per heigth of y = 1 unit, use N*2*pi
        0.62, // minor radius,
        0.62, // major radius,
        1,    // shape parameter, 
        0.0,  // cross section type, (0.0 to 1.0 = square ... rounded to circle
              //                 over 2.0 to 3.0 = rounded to diamond and concave diamond
        45     // cross section rotation angle
      )
  }
  contained_by {box {<-1.5,-5,-1.5>,<1.5,5,1.5>}}
  rotate x*90
  texture {Brass_Texture}
}
background{ color rgb <0,0,0> }
camera {
  location <0, 20, 0>
  sky <0,0,1>
  look_at 0
}
light_source { <20, 10, 0> color White }
object{Screw}

ピッチを表すパラメーターは、1あたりのラジアンで表す。 shape parameterは、ネジ山の角度を表すパラメーターであり、1のときは45度になる。cross section typeは0にすると、尖った理想的なネジになる。しかし、minor radiusとmajor radiusの意味がよく分かっていない。minorを小さくすると、ネジの中央に穴があいてしまう。minorとmajorを等しくすると、穴があかない。その条件の下では、majorがネジの半径にはならないので、適切な値を探して指定した。これはおそらくf_helix1の性質によるものだと思うが、この関数型が分からないので、細かいことは不明である。でも、まずは書けたから一歩前進かな。