# 经纬

garfileo

``````// 天球
sphere {
<0, 0, 0>, 1
texture { pigment { color rgbt <0, 0, 1, 0.75> } }
hollow // 令球体中空
}``````

``MakeFrame(<0, 0, 0>, x, y, z, 1.25, 0.05)``

``````torus {
主半径, 从半径
texture { ... }
}``````

``````#declare line_thickness = 0.015;

// 赤道
torus {
1, line_thickness
texture { pigment { color Orange } }
}

// 北纬 34.61
torus {
#local theta = (34.61 / 180) * pi;
cos(theta), line_thickness
texture { pigment { color Orange } }
translate sin(theta) * y
}``````

``````#declare PrimeMeridian = torus {
1, line_thickness
rotate 90 * z
texture { pigment { color Orange } }
}

// 本初子午线
PrimeMeridian

// 东经 118.41
object {
PrimeMeridian
rotate -118.41 * y
}``````

``#declare Monster = box { <-1.5, -1.5, 0>, <1.5, 1.5, 1.5> }``

``````#declare PrimeMeridian = difference {
torus {
1, line_thickness
rotate 90 * z
texture { pigment { color Orange } }
}
Monster
}``````

``````// 本初子午线
PrimeMeridian

// 东经 118.41
object {
PrimeMeridian
rotate -118.41 * y
}``````

`difference` 和之前用过的 `union`，都是用于组合多个几何体。`difference` 的用法为

``````difference {
foo
bar
}``````

``````// 点 A
#declare A = vrotate(vrotate(-z, 34.61 * x), -118.41 * y);
sphere {
A, PointSize
texture { PointColor }
}``````
：POV Ray 提供的 `vrotate` 函数对给定的向量，遵循左手螺旋定则，绕一个单位向量以给定的角度旋转。

``````#version 3.7;
#include "colors.inc"
global_settings {
assumed_gamma 1.0
}

// 天球
sphere {
<0, 0, 0>, 1
texture { pigment { color rgbt <0, 0, 1, 0.75> } }
hollow // 令球体中空
}

// 世界坐标系
#macro MakeAxis(Origin, Direction, Length, Thickness, Color)
#local ArrowLength = 0.3 * Length;
#local Direction = vnormalize(Direction);
#local Begin = Origin;
#local End = Begin + (Length - ArrowLength) * Direction;
#local ArrowBegin = End;
#local ArrowEnd = ArrowBegin + ArrowLength * Direction;
object {
union {
cylinder {
Begin, End
Thickness
texture { pigment { color Color } }
}
cone {
ArrowBegin, 2 * Thickness
ArrowEnd, 0
texture { pigment { color Color } }
}
}
}
#end

#macro MakeFrame(A, X_A, Y_A, Z_A, L, Thickness)
object {
union {
sphere {
A, 2 * Thickness
texture { pigment { color Gray50 } }
}
MakeAxis(A, X_A, L, Thickness, Red)
MakeAxis(A, Y_A, L, Thickness, Green)
MakeAxis(A, Z_A, L, Thickness, Blue)
}
}
#end

MakeFrame(<0, 0, 0>, x, y, z, 2, 0.025)

#declare line_thickness = 0.015;

torus {
1, line_thickness
texture { pigment { color Orange } }
}

torus {
#local theta = (34.61 / 180) * pi;
cos(theta), line_thickness
texture { pigment { color Orange } }
translate sin(theta) * y
}

#declare Monster = box { <-1.5, -1.5, 0>, <1.5, 1.5, 1.5> }
#declare PrimeMeridian = difference {
torus {
1, line_thickness
rotate 90 * z
texture { pigment { color Orange } }
}
Monster
}

// 本初子午线
PrimeMeridian

// 东经 118.41
object {
PrimeMeridian
rotate -118.41 * y
}

// 点 A
#declare A = vrotate(vrotate(-z, 34.61 * x), -118.41 * y);
sphere {
A, 0.05
texture { pigment { color Gray50 } }
}

light_source {
<5, 5, -5>
color White
}

camera {
orthographic
location <2.0, 2.0, -1.5>
look_at <0, 0, 0>
}
``````
：上述代码中，光源的设置里使用了 `shadowless` 修饰，可以消除物体因光照而产生的影子。相机则使用了 `orthographic` 修饰，设定为平行投影，从而取代了默认的透视投影设定。

5.7k 声望
1.8k 粉丝
0 条评论