1

I am trying to control a moving head camera in a certain direction from my computer. The camera is controlled only by pan (540 degrees) and tilt (280 degrees). The problem is getting the Euler angles to these pan and tilt degrees.

I have a 3d representation of a direction, let's say X Y and Z rotation (Eurler angles).

Now I want to move my (physical!) pan tilt camera in te same direction. But i can't figure out how to translate an xyz vector to pan tilt.

sander
  • 11
  • 1
  • 2
  • Unfortunately we have more than one convention for these angles. Can you tell us what "tilt" is, and perhaps give us one or two unambiguous examples of the directions you're talking about? – Beta Feb 09 '14 at 19:25
  • think of a camera like this: [link](http://img.alibaba.com/wsphoto/v0/347575762/Black-Foscam-CCTV-WiFi-Wireless-IP-Network-WLAN-IR-Pan-Tilt-Camera-FI8908W-Free-shipping-.jpg) The angles are provided by a Kinect skeleton, and are Euler angles – sander Feb 09 '14 at 19:30
  • I want to help you, and I've solved spherical coordinate translation problems before, but I don't like to repeat myself. There are multiple conventions for Euler angles. If you give me three numbers and call them "Euler angles", and I give you two numbers and call them "pan" and "tilt", how will you know they're correct? (And if you say "I'll know because the camera will point in the right direction", I'll walk away.) – Beta Feb 09 '14 at 19:50

1 Answers1

1

switch to orthogonal homogenous 4x4 transform matrices

  • euler angles suck for complex memoizing movement.
  • M is your 4x4 camera transform matrix

rotation around global world X axis by ang:

double c=cos(ang),s=sin(ang);
double Q[16]=
    {
    1, 0, 0, 0,
    0, c,-s, 0,
    0, s, c, 0,
    0, 0, 0, 1
    };
M=M*Q;

rotation around local camera X axis by ang:

double c=cos(ang),s=sin(ang);
double Q[16]=
    {
    1, 0, 0, 0,
    0, c,-s, 0,
    0, s, c, 0,
    0, 0, 0, 1
    };
M=((M^-1)*Q)^-1;

there are libraries for transform matrices like glm but i prefer my own

  • I know many will disagree but mine is here longer than any of the other public one
  • and i am used to it
  • the idea is to remember both direct and inverse matrix of M at all times
  • have a flag which one is updated and which not
  • and before any operation check if the used matrix is relevant
  • if not then compute it from the other one
  • also add count of operation and after reach a treshold
  • do orthogonality or orthonormality check/corrections

here you can see the differences between homogenous (4x4) and normal (3x3+1x3) 3D transform matrices:

Now the driving of camera

  • I will refer to my image inside that link above of 4x4 transform matrix
  • I usually use Z axis as a movement/viewing direction
  • so at start reset your matrix to unit or set it to its position and orientation as you need
  • when you want to rotate use local rotations
  • when you want to move just add to position x0,y0,z0 the ofset you want to move (in global coordinates)
  • so for move forward if d units do this:

    x0+=d*Zx;
    y0+=d*Zy;
    z0+=d*Zz;
    
  • for side movement use X vector

  • for up/down use Y vector
  • for rotations different then around X axis just use different Q matrix

  • rotation around Y-axis

     c, 0, s, 0,
     0, 1, 0, 0,
    -s, 0, c, 0,
     0, 0, 0, 1;
    
  • rotation around Z-axis

     c,-s, 0, 0,
     s, c, 0, 0,
     0, 0, 1, 0,
     0, 0, 0, 1;
    
Community
  • 1
  • 1
Spektre
  • 49,595
  • 11
  • 110
  • 380