Last updated: March 2008. Kajiyama             [ 目次に戻る ]

立体図形を表現する座標系


立体図形の形状,図形の配置,カメラ,光源の位置や方向はすべて座標で表現する.

このとき使用するX軸・Y軸・Z軸の3軸の位置関係は左手系と右手系の座標系がある.

CGの世界ではスクリーン窓をX-Y平面とする左手系が使われており,これまで皆さんが数学で学んだ右手系の座標軸とは異なるので,慣れるまでは努力が必要である.

左手系 (スクリーン窓をX-Y平面とする)  右手系 (これまで学んだ数学に基づく/地面をX-Y平面とする)

PovRayは左手系を使用する

サンプル box01-left.pov

//box01-left.pov
// POV-Ray 3.6 scene file by Kajiyama

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


//カメラ設定
camera{
location < 15,15,15>
look_at <0,0,2>
angle 60
}

//ライト設定
light_source{
<15,25,19> color White*1.7
}

// XYZ座標空間
/*
// チェック柄の床
object{
Plane_XY
pigment{checker color Gray color White*0.9}
translate <0,0,0>
}
*/

// 座標系の表示
// Z軸
cylinder{<0,0,-5>,<0,0,7>,0.05
pigment{color Red}
finish{phong 1 reflection 0.1}
}
cone{<0,0,7>,0.3
<0,0,8.5>,0
pigment{color Red}
}
// Z文字
cylinder{<-0.5,0.5,0>,<0.5,0.5,0>,0.08
pigment{color Red}
finish{phong 1 reflection 0.1}
translate <0,1.1,9>
}
cylinder{<0.5,0.5,0>,<-0.5,-0.5,0>,0.08
pigment{color Red}
finish{phong 1 reflection 0.1}
translate <0,1.1,9>
}
cylinder{ <-0.5,-0.5,0>, <0.5,-0.5,0>,0.08
pigment{color Red}
finish{phong 1 reflection 0.1}
translate <0,1.1,9>
}
// X軸
cylinder{<-5,0,0>,<7,0,0>,0.05
pigment{color Green}
finish{phong 1 reflection 0.1}
}
cone{<7,0,0>,0.3
<8.5,0,0>,0
pigment{color Green}
}
// X文字
cylinder{<-0.5,-0.5,0>,<0.5,0.5,0>,0.08
pigment{color Green}
finish{phong 1 reflection 0.1}
rotate y*90
translate <9,1.1,0>
}
cylinder{ <-0.5,0.5,0>, <0.5,-0.5,0>,0.08
pigment{color Green}
finish{phong 1 reflection 0.1}
rotate y*90
translate <9,1.1,0>
}
// Y軸
cylinder{<0,-5,0>,<0,7,0>,0.05
pigment{color Blue}
finish{phong 1 reflection 0.1}
}
cone{<0,7,0>,0.3
<0,8.5,0>,0
pigment{color Blue}
}
// Y文字
cylinder{<-0.5,0.5,0>,<0,0,0>,0.08
pigment{color Blue}
finish{phong 1 reflection 0.1}
translate <0,9,0>
}
cylinder{<0.5,0.5,0>,<0,0,0>,0.08
finish{phong 1 reflection 0.1}
translate <0,9,0>
}
cylinder{ <0,0,0>, <0,-0.5,0>,0.08
pigment{color Blue}
finish{phong 1 reflection 0.1}
translate <0,9,0>
}

//■■■ボックスの座標表現 ■■■
box{<0,0,0>,<5,5,5> //頂点の座標を指定する
pigment{color rgb<0.5,0.8,0.4>}
}

background{color White}

PovRayを左手系から右手系へ変更

サンプルbox01-right.pov

//box01-right.pov
// POV-Ray 3.6 scene file by Kajiyama

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


//カメラ設定
camera{
location < 15,15,15>
right <-1.33, 0, 0> //右手系のために必要な座標変換
sky <0, 0, 1>//天空の方向の変換
//サンプルbox01-left.povに、この2行を追加する■■■
look_at <0,0,2>
angle 60
}

//ライト設定
light_source{
<15,25,19> color White*1.7
}

// XYZ座標空間
/*
// チェック柄の床
object{
Plane_XY
pigment{checker color Gray color White*0.9}
translate <0,0,0>
}
*/

// 座標系の表示
// Z軸
cylinder{<0,0,-5>,<0,0,7>,0.05
pigment{color Red}
finish{phong 1 reflection 0.1}
}
cone{<0,0,7>,0.3
<0,0,8.5>,0
pigment{color Red}
}
// Z文字
cylinder{<-0.5,0.5,0>,<0.5,0.5,0>,0.08
pigment{color Red}
finish{phong 1 reflection 0.1}
translate <0,1.1,9>
}
cylinder{<0.5,0.5,0>,<-0.5,-0.5,0>,0.08
pigment{color Red}
finish{phong 1 reflection 0.1}
translate <0,1.1,9>
}
cylinder{ <-0.5,-0.5,0>, <0.5,-0.5,0>,0.08
pigment{color Red}
finish{phong 1 reflection 0.1}
translate <0,1.1,9>
}
// X軸
cylinder{<-5,0,0>,<7,0,0>,0.05
pigment{color Green}
finish{phong 1 reflection 0.1}
}
cone{<7,0,0>,0.3
<8.5,0,0>,0
pigment{color Green}
}
// X文字
cylinder{<-0.5,-0.5,0>,<0.5,0.5,0>,0.08
pigment{color Green}
finish{phong 1 reflection 0.1}
rotate y*90
translate <9,1.1,0>
}
cylinder{ <-0.5,0.5,0>, <0.5,-0.5,0>,0.08
pigment{color Green}
finish{phong 1 reflection 0.1}
rotate y*90
translate <9,1.1,0>
}
// Y軸
cylinder{<0,-5,0>,<0,7,0>,0.05
pigment{color Blue}
finish{phong 1 reflection 0.1}
}
cone{<0,7,0>,0.3
<0,8.5,0>,0
pigment{color Blue}
}
// Y文字
cylinder{<-0.5,0.5,0>,<0,0,0>,0.08
pigment{color Blue}
finish{phong 1 reflection 0.1}
translate <0,9,0>
}
cylinder{<0.5,0.5,0>,<0,0,0>,0.08
finish{phong 1 reflection 0.1}
translate <0,9,0>
}
cylinder{ <0,0,0>, <0,-0.5,0>,0.08
pigment{color Blue}
finish{phong 1 reflection 0.1}
translate <0,9,0>
}

//■■■ボックスの座標表現 ■■■
box{<0,0,0>,<5,5,5> //頂点の座標を指定する
pigment{color rgb<0.5,0.8,0.4>}
}

background{color White}

[ 目次に戻る ]