POV-rayメモ

平成21年5月5日 更新

 このページでは、便利なPOV-rayメモを残してあります。

●例(フェロセン)

 フェロセンの基本は、下記の通りです。

#include "colors.inc"
#include "shapes.inc"
#include "metals.inc"

camera {
right<-1.333,0,0>
location <0, -10, 0>
look_at <0, 0, 0>
angle 55
}

light_source { < 8, 0, 8> color White }
light_source { < 0, -8, 8> color White }

#declare Font="cyrvetic.ttf"
text{ ttf Font
concat("Ferrocene"),0.1,0
scale <1, 1, 3>
rotate 75*x
translate <-2, -2.5, -2.5>
texture{T_Gold_2B}
}

object{
Plane_XZ
texture{T_Silver_2B}
translate<0,2.5, 0>
}

object{
Plane_YZ
texture{T_Silver_2B}
translate<-2.5,0, 0>
}

sphere { < 0.00, 0.00, 0.00>, 1.0 texture { T_Gold_2B } }

sphere { < 1.19, 0.00, 1.61>, 0.5 texture { T_Gold_2B } }
sphere { < 0.37, 1.13, 1.61>, 0.5 texture { T_Gold_2B } }
sphere { <-0.96, 0.70, 1.61>, 0.5 texture { T_Gold_2B } }
sphere { <-0.96, -0.70, 1.61>, 0.5 texture { T_Gold_2B } }
sphere { < 0.37, -1.13, 1.61>, 0.5 texture { T_Gold_2B } }

sphere { < 2.19, 0.00, 1.61>, 0.3 texture { T_Gold_2B } }
sphere { < 0.68, 2.08, 1.61>, 0.3 texture { T_Gold_2B } }
sphere { <-1.77, 1.29, 1.61>, 0.3 texture { T_Gold_2B } }
sphere { <-1.77, -1.29, 1.61>, 0.3 texture { T_Gold_2B } }
sphere { < 0.68, -2.08, 1.61>, 0.3 texture { T_Gold_2B } }

sphere { <-1.19, 0.00,-1.61>, 0.5 texture { T_Gold_2B } }
sphere { <-0.37, -1.13,-1.61>, 0.5 texture { T_Gold_2B } }
sphere { < 0.96, -0.70,-1.61>, 0.5 texture { T_Gold_2B } }
sphere { < 0.96, 0.70,-1.61>, 0.5 texture { T_Gold_2B } }
sphere { <-0.37, 1.13,-1.61>, 0.5 texture { T_Gold_2B } }

sphere { <-2.19, 0.00,-1.61>, 0.3 texture { T_Gold_2B } }
sphere { <-0.68, -2.08,-1.61>, 0.3 texture { T_Gold_2B } }
sphere { < 1.77, -1.29,-1.61>, 0.3 texture { T_Gold_2B } }
sphere { < 1.77, 1.29,-1.61>, 0.3 texture { T_Gold_2B } }
sphere { <-0.68, 2.08,-1.61>, 0.3 texture { T_Gold_2B } }

cylinder { < 1.19, 0.00, 1.61>, < 0.37, 1.13, 1.61>, 0.15 texture { T_Gold_2B } }
cylinder { < 0.37, 1.13, 1.61>, <-0.96, 0.70, 1.61>, 0.15 texture { T_Gold_2B } }
cylinder { <-0.96, 0.70, 1.61>, <-0.96, -0.70, 1.61>, 0.15 texture { T_Gold_2B } }
cylinder { <-0.96, -0.70, 1.61>, < 0.37, -1.13, 1.61>, 0.15 texture { T_Gold_2B } }
cylinder { < 0.37, -1.13, 1.61>, < 1.19, 0.00, 1.61>, 0.15 texture { T_Gold_2B } }

cylinder { <-1.19, 0.00,-1.61>, <-0.37, -1.13,-1.61>, 0.15 texture { T_Gold_2B } }
cylinder { <-0.37, -1.13,-1.61>, < 0.96, -0.70,-1.61>, 0.15 texture { T_Gold_2B } }
cylinder { < 0.96, -0.70,-1.61>, < 0.96, 0.70,-1.61>, 0.15 texture { T_Gold_2B } }
cylinder { < 0.96, 0.70,-1.61>, <-0.37, 1.13,-1.61>, 0.15 texture { T_Gold_2B } }
cylinder { <-0.37, 1.13,-1.61>, <-1.19, 0.00,-1.61>, 0.15 texture { T_Gold_2B } }

cylinder { < 1.19, 0.00, 1.61>, < 2.19, 0.00, 1.61>, 0.15 texture { T_Gold_2B } }
cylinder { < 0.37, 1.13, 1.61>, < 0.68, 2.08, 1.61>, 0.15 texture { T_Gold_2B } }
cylinder { <-0.96, 0.70, 1.61>, <-1.77, 1.29, 1.61>, 0.15 texture { T_Gold_2B } }
cylinder { <-0.96, -0.70, 1.61>, <-1.77, -1.29, 1.61>, 0.15 texture { T_Gold_2B } }
cylinder { < 0.37, -1.13, 1.61>, < 0.68, -2.08, 1.61>, 0.15 texture { T_Gold_2B } }

cylinder { <-1.19, 0.00,-1.61>, <-2.19, 0.00,-1.61>, 0.15 texture { T_Gold_2B } }
cylinder { <-0.37, -1.13,-1.61>, <-0.68, -2.08,-1.61>, 0.15 texture { T_Gold_2B } }
cylinder { < 0.96, -0.70,-1.61>, < 1.77, -1.29,-1.61>, 0.15 texture { T_Gold_2B } }
cylinder { < 0.96, 0.70,-1.61>, < 1.77, 1.29,-1.61>, 0.15 texture { T_Gold_2B } }
cylinder { <-0.37, 1.13,-1.61>, <-0.68, 2.08,-1.61>, 0.15 texture { T_Gold_2B } }

●カメラを動かす

 例えば、カメラを次のように動かします。

camera {
right<-1.333,0,0>
location <0, 1-5.5*clock, 3-1.5*clock>
look_at <0, 0, 0>
angle 39+5.5*clock
}

●座標データが大量にある場合には(フラーレンなど)

 データをいったん配列変数に取り込み、球も結合も、ループと条件で書き出します。

#declare XYZr =
array[21][4] // 21原子、4項目(x, y, z, 半径)。ただし0-20と0-3になります。
{
{ 0.00, 0.00, 0.00, 1.0}
{ 1.19, 0.00, 1.61, 0.5}
{ 0.37, 1.13, 1.61, 0.5}
{-0.96, 0.70, 1.61, 0.5}
{-0.96, -0.70, 1.61, 0.5}
{ 0.37, -1.13, 1.61, 0.5}
{ 2.19, 0.00, 1.61, 0.3}
{ 0.68, 2.08, 1.61, 0.3}
{-1.77, 1.29, 1.61, 0.3}
{-1.77, -1.29, 1.61, 0.3}
{ 0.68, -2.08, 1.61, 0.3}
{-1.19, 0.00,-1.61, 0.5}
{-0.37, -1.13,-1.61, 0.5}
{ 0.96, -0.70,-1.61, 0.5}
{ 0.96, 0.70,-1.61, 0.5}
{-0.37, 1.13,-1.61, 0.5}
{-2.19, 0.00,-1.61, 0.3}
{-0.68, -2.08,-1.61, 0.3}
{ 1.77, -1.29,-1.61, 0.3}
{ 1.77, 1.29,-1.61, 0.3}
{-0.68, 2.08,-1.61, 0.3}
}

#declare I=0;
#while (I < 21)
sphere { < XYZr[I][0], XYZr[I][1], XYZr[I][2] >, XYZr[I][3] texture { T_Gold_2B } }
#declare I=I+1;
#end

#declare I=0;
#while (I < 20) // 原子数より一つ少なくします。
#declare J=I+1;
#while (J < 21)
#if ( pow( XYZr[I][0]-XYZr[J][0], 2 ) + pow( XYZr[I][1]-XYZr[J][1], 2) +
pow( XYZr[I][2]-XYZr[J][2], 2) < pow( 1.8, 2) // 距離が1.8の場合
)
cylinder { < XYZr[I][0], XYZr[I][1], XYZr[I][2] >,
< XYZr[J][0], XYZr[J][1], XYZr[J][2] >, 0.15 texture { T_Gold_2B } }
#end
#declare J=J+1;
#end
#declare I=I+1;
#end

●結合距離を細かく判断する方法(劔持の方法)

#declare I=0;
#while (I < 91)
#declare J=I+1;
#while (J < 92)
#switch ( pow(XYZr[I][0]-XYZr[J][0],2)+
pow(XYZr[I][1]-XYZr[J][1],2)+
pow(XYZr[I][2]-XYZr[J][2],2)
)
#range ( pow( 0.8,2) , pow( 1.5,2) )
#range ( pow( 2.5,2) , pow( 2.6,2) )
#range ( pow( 1.8,2) , pow( 1.85,2) )
cylinder { < XYZr[I][0], XYZr[I][1], XYZr[I][2] >,
< XYZr[J][0], XYZr[J][1], XYZr[J][2] >, 0.1 texture { T_Glass1 } }
#end
#declare J=J+1;
#end
#declare I=I+1;
#end