Tag Info

Hot answers tagged

2

user1118321's answer will provide you the correct answer, though it is more general than necessary. Since we're dealing with a right triangle, the easiest solution is to use the definition of the tangent function: tan(α) = A / B Substituting half the height of the screen, the z coordinate of the camera, and half the vertical field of view gets us: ...


2

Check out the Law of Cosines. It allows you to calculate any side or angle in a triangle if you have the opposite 2 angles or sides. Or alternately, use the law of sines (described at the bottom of the above link). In your case, you know that vertical field of view is 45 degrees and that the base side you want is the height of the screen. You can think of ...


1

When you rotate your camera you should apply the same rotation matrix to your up vector. That should result in an up vector in the same direction as your view matrix's up direction.


1

You should probably use glm::angleAxis() (documentation here): glm::quat &rot = glm::angleAxis(glm::radians(90.f), glm::vec3(0.f, 1.f, 0.f));


1

the glm::quat(float, float, float, float); constructor doesn't do what you think it does. It sets the values directly. The values of the quaternion (w, x, y, z) are in order: the cosine of half the angle, the sine of half the angle times the x coordinate of the normalized rotation axis, and the same for the y ans z components. So instead you want to use ...


1

The bug quite likely comes from angleAxis requiring a normalized vector (see quaternion.inl in the source code). You need to call normalize() on the cross product result. (you might be interested in my article about creating a quaternion from two vectors without using trigonometry functions)


1

Your top code chunk is: t2 * (t1 * direction * inverse(t1)) * inverse(t2) Your bottom chunk is: t3 * direction * inverse(t3) Given that t3 = t2 * t1 It's (t2 * t1) * direction * inverse(t2 * t1) As far as my knowledge of Quaternion multiplication goes, I don't think t2 * (t1 * direction * inverse(t1)) * inverse(t2) and (t2 * t1) * direction * ...



Only top voted, non community-wiki answers of a minimum length are eligible