0
\$\begingroup\$

Is there anything inherently wrong, if you derive your view matrix from 2 spherical coordinates (say, phi and theta) on the unit sphere? The z-axis vector would be at, say (phi, theta), the y-axis at (phi, theta-90) and the x-axis vector at, say, (phi-90,theta). You would convert the points into Cartesian coordinate system and put them into view matrix rows to obtain the view matrix. I never read about people using such a camera specification on SO or here, so is there something wrong with it?

\$\endgroup\$
5
  • \$\begingroup\$ Don't ask for permission, just do it and ask for help if it goes wrong. ;) Even if no developer on Earth had done this before, if it works for your case, that's all you need. But yes, storing a camera orientation as angles and building a matrix from that is a common approach. Have you encountered any trouble putting this into practice? \$\endgroup\$
    – DMGregory
    Commented Jun 26, 2018 at 12:21
  • \$\begingroup\$ @DMGregory No, I don't have any problem with this approach, but I'm not a rendering/shading guru. Some people swear, say, by quaternions and it's supposedly better to use them for some reason, that I can't comprehend atm. \$\endgroup\$ Commented Jun 26, 2018 at 12:25
  • \$\begingroup\$ Quaternions are good when you're trying to compute rotations — like interpolating between two rotation keyframes, or stacking one rotation on top of/relative to another — without biases along particular axes or poles. If you haven't found a need for them in your camera logic yet, then it's probably because you don't need them for what you're doing. Camera control is one case where we often want bias & poles (eg in a typical FPS camera where we can yaw 360° but only pitch ±90° or less) \$\endgroup\$
    – DMGregory
    Commented Jun 26, 2018 at 12:27
  • \$\begingroup\$ I can delete my question, if you want. I just find it hard to know, where the camera is pointed at, if it is specified with a quat, or even 3 euler angles, while with unit sphere angles I know immediately where the camera is pointed at. \$\endgroup\$ Commented Jun 26, 2018 at 13:02
  • \$\begingroup\$ Then do it the way you find clear. It doesn't sound like you need anything from us here. Unless you'd like to ask how to determine the facing direction from Euler angles or quaternions. (Hint: Euler angles are just the two angles you're already using, plus an extra one for rolling the camera about its view axis) \$\endgroup\$
    – DMGregory
    Commented Jun 26, 2018 at 13:06

0

You must log in to answer this question.

Browse other questions tagged .