1
\$\begingroup\$

I am having an issue constructing my transformation matrices, for this sphere problem.

enter image description here

I know the 3d coordinate of the center, and the radius of, the sphere.

Since I know the radius and center of the sphere, it's easy to compute all positions on the sphere, but I'm not sure how I should compute the rotation matrix?

Each point has to be rotated such that it points toward the object, and the only thing that tells me the orientation of the vector is the difference between the 3d point on sphere and the 3d point of the object.. But one vector doesn't seem enough to construct a whole rotation matrix?...

Could I extract a rotation matrix, that "tells" the point how it should be rotated to look at the object?

\$\endgroup\$
0
\$\begingroup\$

Indeed, you need an additional orientation hint for this to work.

It is quite common to use an “up” vector in addition to the view vector that you computed. Most 3D libraries have some kind of “lookat” function: Transform.LookAt in Unity3D, glm::lookAt in glm, or the deprecated gluLookAt in ancient OpenGL.

Note that if the “up” vector is constant or only depends on the position, you will have discontinuities in the resulting transformation. This is mathematically unavoidable. One possibility is to use e.g. (0,0,1) as a constant “up” vector, and just disallow the viewer from being exactly in (0,0,1) or (0,0,-1).

\$\endgroup\$
  • \$\begingroup\$ I did read a bit about the up vector.. which might help me?.. I am not using any form of 3d library, so i have to compute it using mathematics. \$\endgroup\$ – Lamda Apr 23 '16 at 10:41
  • \$\begingroup\$ It seems like the up vector should be perpendicular to the my orient vector?.. but it does not seem like that 0,0,1 is always perpendicular to that.. \$\endgroup\$ – Lamda Apr 23 '16 at 10:47
  • \$\begingroup\$ I am sure i understand the problem.. Could you demonstrate with an illustration? \$\endgroup\$ – Lamda Apr 23 '16 at 11:08
  • \$\begingroup\$ Will gimbal lock be an issue here? \$\endgroup\$ – Lamda Apr 23 '16 at 11:21
  • \$\begingroup\$ No, the up vector is just a general hint, it does not have to be perpendicular to your view vector. It just has to be non-collinear. Gimbal lock is related to this, but probably not an issue for you. \$\endgroup\$ – sam hocevar Apr 23 '16 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.