2021-05-10

关于光线追踪:下一周的球...


文章更新中

就是文中这段代码的三角函数部分

1
2
3
4
5
6
7
8
9
10
11
12
13
static void getSphereUV(const point3& p, double& u, double& v) {
// p: a given point on the sphere of radius one, centered at the origin.
// u: returned value [0,1] of angle around the Y axis from X=-1.
// v: returned value [0,1] of angle from Y=-1 to Y=+1.
// <1 0 0> yields <0.50 0.50> <-1 0 0> yields <0.00 0.50>
// <0 1 0> yields <0.50 1.00> < 0 -1 0> yields <0.50 0.00>
// <0 0 1> yields <0.25 0.50> < 0 0 -1> yields <0.75 0.50>
auto theta = acos(-p.y());
auto phi = atan2(-p.z(), p.x()) + pi;

u = phi / (2*pi);
v = theta / pi;
}

第四章没有配图,一开始我也没看懂uv坐标,自己画画图就好了