My world is a field. The coordinates and the axis are described in the image below:
[ATTACH=CONFIG]1397[/ATTACH]
I want to locate a camera above the field, at location C=(W/2,H/2,-Z1), facing down. The extrinsic matrix RT that I should get for this is:
(1, 0, 0, W/2)
(0, 1, 0, H/2)
(0, 0, 1, Z1 )
(0, 0, 0, 1 )
I want to get the RT using gluLookAt equivalent method described here. I had to modify vz calculation by adding minus since I locate the camera along the -Z axis and not +Z axis.
static Mat4x4 lookAt(Vec3 eye, Vec3 target, Vec3 up)
{
// the vector to the target is in the negative z direction.
Vec3 vz = -(target - eye).normalize();
Vec3 vx = vnl_cross_3d(up, vz).normalize();
Vec3 vy = vnl_cross_3d(vz, vx);
Mat4x4 inverseViewMatrix;
inverseViewMatrix.set_row(0, Vec4( vx[0], vy[0], vz[0], eye[0] ));
inverseViewMatrix.set_row(1, Vec4( vx[1], vy[1], vz[1], eye[1] ));
inverseViewMatrix.set_row(2, Vec4( vx[2], vy[2], vz[2], eye[2] ));
inverseViewMatrix.set_row(3, Vec4( 0 , 0 , 0 , 1 ));
Mat4x4 result = vnl_inverse(inverseViewMatrix);
return result;
}
To get the desired RT here are the eye, target and up that I define:
Vec3 eye(W/2,H/2,-Z1); //location relative to world left-top (0,0,0)
Vec3 target(W/2,H/2,0); //location of point on field relative to world left-top (0,0,0)
Vec3 up(0,-1,0);
RT = lookAt(eye, target, up);
But, the RT I get is not the one that I should get (the one that described above). What eye, target and up I should define to the desired RT?