11.2 等値面(isosurface)

等値面(isosurface)とは、POV-Rayでは指定された範囲内において、指定した関数の等値面を作成する機能である。組み込み関数などを組み合わせることでさまざまな面を定義することができる。

< isosurface の構文>


isosurface {

  function { FUNCTION_ITEMS }

  [ contained_by { SPHERE | BOX } ]

  [ threshold FLOAT_VALUE ]

  [ accuracy FLOAT_VALUE ]

  [ max_gradient FLOAT_VALUE ]

  [ evaluate P0, P1, P2 ]

  [ open ]

  [ max_trace INTEGER ] | [ all_intersections ]

  [ OBJECT_MODIFIERS... ]

}

isosurface 等値面を指定するキーワード
function { FUNCTION_ITEMS } 等値面を定義する関数の指定 ⇒「11.2-5 関数」
contained_by { SPHERE | BOX } 等値面を生成する範囲の指定、球またはボックスで指定する。[ディフォルト:box{-1,1} ]  ⇒「11.2-1 生成範囲」
threshold FLOAT_VALUE 等値面を生成するための値(閾値)の指定 [ディフォルト:0]  ⇒「11.2-2 閾値」
accuracy FLOAT_VALUE 再帰分割の値の指定、小さいほど正確な値が得られる。[ディフォルト:0.001]
max_gradient FLOAT_VALUE 関数の最大勾配の指定 [ディフォルト:1.1]  ⇒「11.2-3 最大勾配関数」
evaluate P0, P1, P2 最大勾配を動的に探索する機能。P0は最小値、P1は最大値、P2は減衰値で指定する。
open contained_byで指定された物体の形状を生成しない指定、等値面のみの生成となる。[ディフォルト:生成する]  ⇒「11.2-4 オープン」
max_trace INTEGER CSGにおける交差面のチェック回数の指定
all_intersections CSGにおける交差面を全てチェックする。
OBJECT_MODIFIERS... 変形などの指定


11.2-1 生成範囲(contained_by)

contained_byで面の生成範囲を指定する。生成範囲は、ボックスまたは球で範囲指定を行う。図11.2-1は、生成範囲であるボックスの中に等値面である円錐が生成されている。この図ではわかり易いようにボックスを半透明で描いている。


図11.2-1 生成範囲ボックスと等値面

  isosurface {

    function { sqrt(pow(x,2) + pow(y,2)) + z }

    contained_by { box { -2, 2 } }

    max_gradient 1.8

    pigment{color rgb<1,0.88,0.65>}

  }


11.2-2 閾値(threshold)

 閾値(threshold)は等値面の値、つまり等値のことである。次式は、半径が2の球の式である。

  sqrt(pow(x,2) + pow(y,2) + pow(z,2)) = 2

POV-Rayにおける等値面の記述は、閾値(threshold)を用いて次のようになる。


        isosurface {

           function { sqrt(pow(x,2) + pow(y,2) + pow(z,2)) }

           contained_by { box { -2, 2 } }

           threshold 2

        }

または、次の記述でもよい。


        isosurface {

           function { sqrt(pow(x,2) + pow(y,2) + pow(z,2)) - 2 }

           contained_by { box { -2, 2 } }

        }


11.2-3 最大勾配(max_gradient)

関数の最大勾配の指定をする。値が低すぎると、割れ目ができたり穴が開いたりするが、高すぎると計算が遅くなる。必要に応じて値を調整する必要がある。図11.2-3の左側の等値面はmax_gradientを3としたもので、右側の等値面は max_gradientを省略しているので、ディフォルトの1.1となっている。


図11.2-3 最大勾配の値による比較

  //---------------Left

  isosurface {

     function { pow(x,2) + z - 0.5 }

     contained_by { box { -2, 2 } }

     max_gradient 3 

     pigment{color rgb<1,0.88,0.65>}  

     translate <2,0,1>

   }

  //---------------Right

  isosurface {

     function { pow(x,2) + z - 0.5 }

     contained_by { box { -2, 2 } }

     pigment{color rgb<1,0.88,0.65>}

     translate <-2,0,1>

   }


11.2-4 オープン(open)

等値面は、contained_by で指定された形状(ボックスまたは球)の内側で生成される。等値面と生成範囲の立体が交差するとき、その交差面もディフォルトで生成される。openはこのような面を生成しない指定である。図11,2-4は、openを指定した2つの等値面を表している。


図11.2-4 オープンを指定した等値面

  //----------------Left

  isosurface {

    function { pow(x,2) + z - 0.5 }

    contained_by { box { -2, 2 } }

    max_gradient 3 

    open 

    pigment{color rgb<1,0.88,0.65>}

    translate <2,0,1> 

  }  

  //----------------Right

  isosurface {

    function { sqrt(pow(x,2) + pow(z,2)) - 1 }

    contained_by { box { -2, 2 } }

    max_gradient 3 

    open

    pigment{color rgb<1,0.88,0.65>}   

    translate <-2,0,0> 

  }  


11.2-5 関数(function)

関数の作り方しだいで、単純な形状から複雑なものまでさまざまな3次元面を作成することができる。functions.inc に定義されいる関数を使うことができる。次にいくつか例を示す。

図11.2-5a 平面式による等値面

  isosurface {

    function { x + y + z } 

    contained_by { box { -2, 2 } }

    max_gradient 1.8

    pigment{color rgb<0.8,0.75,0.55>}

  }

図11.2-5b ノイズ関数による等値面1

  isosurface {

     function { f_noise3d(x, y, z) - 0.5 } 

    contained_by { box { -2, 2 } }

    max_gradient 1.8

    pigment{color rgb<0.8,0.75,0.55>}

  }

図11.2-5c ノイズ関数による等値面2

  isosurface {

    function { z + f_noise3d(x, y, 0) }

    contained_by { box { -3,3 } }

    max_gradient 1.8

    pigment{color rgb<0.8,0.75,0.55>} 

  }

図11.2-5d ノイズ関数による等値3面

  isosurface {

    function { f_sphere(x, y, z, 1.6) 

               - f_noise3d(x*5, y*5, z*5)*0.5 }

    contained_by { box { -2, 2 } }

    max_gradient 3

    pigment{color rgb<0.8,0.75,0.55>} 

  }


11.2-6 関数の応用

関数の論理演算を行うことで、CSGと同じように物体の論理和、論理積、論理差により物体を生成することができる。また、ブロブも使用することができる。

(a) 論理和: min 関数の使用
図11.2-6a 関数の論理和

  #declare fn_A=function{sqrt(pow(y,2)+pow(z,2))-0.8}

  #declare fn_B=function{abs(x)+abs(z)-1}

  isosurface {

    function { min( fn_A(x,y,z), fn_B(x,y,z) ) }

    contained_by { box { -2, 2 } }

    max_gradient 1.8 

    texture {T_Grnt1}

    scale 1.8

  }

(b) 論理積: max 関数の使用
図11.2-6b 関数の論理積

  #declare fn_A=function{sqrt(pow(y,2)+pow(z,2))-0.8}

  #declare fn_B=function{abs(x)+abs(z)-1}

  isosurface {

     function { max( fn_A(x,y,z), fn_B(x,y,z) ) }

     contained_by { box { -2, 2 } }

     max_gradient 1.8

     texture {T_Grnt1}

         scale 1.8

  }

(c) 論理差: min 関数、引く関数に-をつける。
図11.2-6c 関数の論理差

  #declare fn_A=function{sqrt(pow(y,2)+pow(z,2))-0.8}

  #declare fn_B=function{abs(x)+abs(z)-1}

  isosurface {

     function { max( fn_A(x,y,z), -fn_B(x,y,z) ) }

     contained_by { box { -2, 2 } }

     max_gradient 1.8  

     texture {T_Grnt1}

     scale 1.8

  }

(d)ブロブ
図11.2-6d 関数のブロブ

  #declare fn_A=function{sqrt(pow(y,2)+pow(z,2))-0.8}

  #declare fn_C=function{abs(x)+abs(y)-1}

  #declare Blob_threshold=0.01;

  isosurface {

     function {

       1+Blob_threshold

          - pow( Blob_threshold, fn_A(x,y,z) ) 

          - pow( Blob_threshold, fn_C(x,y,z) )

      }

     contained_by { box { -2, 2 } } 

     max_gradient 6

     texture {T_Wood7 scale 0.5}

     scale 1.4

  }