【发布时间】:2015-07-01 02:15:39
【问题描述】:
我正在阅读计算机图形学的基础知识并尝试设置我自己的光线追踪器。这本书说“构造相机框架的最常见方法是从视点,它变成e,视图方向,它是-w,以及向上向量,它用于构建一个基础,其中有v和w由视图方向和向上方向定义的平面"
但后来我遇到了How to move a camera using in a ray-tracer?,它说我们需要通过与相机方向 (w) 执行叉积来校正(斜率?)的向上向量。这是为什么呢?
我正在使用lookAt(0,0,0) 和up(0,1,0) 调用我的相机设置
// a camera can be constructed using a position, direction and an up vector
Camera::Camera(Vector position, Vector lookAt, Vector up) {
this->position = position;
this->lookAt = lookAt;
// the difference between camera position and where we want
// to look at is the direction of the camera
Vector direction = lookAt.diff(position);
// camera frame
w = direction.normalize();
v = up.cross(w).normalize(); // right vector
// which is the correct up?
u = up.normalize();
printf("%.2f %.2f %.2f\n", u.getX(), u.getY(), u.getZ()); // prints 0 1 0
u = v.cross(w).normalize(); // the up vector
printf("%.2f %.2f %.2f\n", u.getX(), u.getY(), u.getZ()); // prints 0.31 -0.86 -0.41
}
【问题讨论】:
-
它是 slop,而不是 slope。
标签: camera raytracing