As you can see I'm new into this field, and I don't know how to solve the following simple problem.
Let's say I wish to move an object from point A in point B. I know the x, y coordinates of A and B. How can I detect the rotation angle between A and B, using a matrix.
All I can do is to solve this problem is using Pythagoras theorem, but I need to understand how to do it using matrices.
Method 1: Write everything in polar and subtract angles.
Method 2: Use trigonometry to find the angle from x (or y) axis to A, and x (or y) axis to B, and subtract. (This is really the same as method 1.)
I don't know what you could mean by "as a matrix" since you are going from 4 values (x and y coordinates) to 1 value (the angle theta).
Yes, like tabstop says. You can, however "move" the object using a matrix by putting the sin/cos values in a matrix and multiplying the current coordinates by the new values. #
Check out "Transformation Matrix":
Well, that depends on what you want. If you want the angle between A and B simple trig is the best solution. If you have A and the angle and want to fidn B then use a rotation matrix.
| 1 0 0 0 |
| 0 1 0 0 |
| 0 0 1 0 |
| x y z 1 |
is your initial point A
| cos sin 0 0 |
| -sin cos 0 0 |
| 0 0 1 0 |
| 0 0 0 1 |
is your rotation matrix for theta
then you simply multiply them and the product gives you a new 4x4 matrix for the point B. This is assuming you want to use computer hardware. If you want the fastest method on paper, then use the 1x4 point matrix instead, which i believe is
| X |
| Y |
| Z |
| 1 |
then multiply it by the 4x4 rotationmatrix above, which results in a new 1x4 point matrix
That's for 3d. For 2d, you basically drop one dimension. The point is
| 1 0 0 |
| 0 1 0 |
| x y 1 |
The rotation matrix is
| cos sin 0 |
| -sin cos 0 |
| 0 0 1 |
yeah I gave the 3d for the simple fact its supported directly in hardware, 2d is not. 3d is also supprted directly by DirectX
Many thx for you valuable replays. Now I'm taking the pencil to begin to learn about transformation matrix.
I'll tell you which is my real problem. I'm in the last year in computer science and i have to detect head rotation angles. It's about detecting yaw, pitch, roll angles. All I know is that I can use Euleur angles or quaternions.
The project is in C++. The user has to chose the a, b, c dots for mouth, left eye and right eye respectively and my application to return the yaw, pitch, roll angles.
Until now I can get the a,b, c coordinates in 2D as mouse events.
Which is the next step? Many thanks.
Are any libs which I can use in order to obtain those angles, when I have x, y coordinates for each point?
ps: sorry for my bad English, It's not my native language. If I sad something bad, pls tell me and I'll rephrase.
atan2f() will give you the angle.
We worked on a similar problem awhile ago. The problem si that the segments AB BC abd CA are not of uniform size for any two people, plus you have to determien the distance. Since the proportions change with distance and with person, it is fairly difficult to get a perfectly accurate answer on yaw pitch and roll for their gaze. The best we coudl do using neural networks was to get a fairly close approximation, it was still off by as much as 15-20 degrees though. For a single person or sample population you can get much mroe accurate, btu theres no guarantee that accuracy will hold for untested examples.
I need the head angles. A transformation from 2D in 3D.
I think I've find something: Estimation of Head Orientation Using Characteristic Points of
Face see chapter 5.2 on page 44.
Allot of math is involved here :(. I'm afraid.
You need to take into account the height of the camera b/c even though their heads might be level they appear to be angled due to perspective projection and camera height. You also have no depth information for this image.
If you can determine the look vector of the heads then the rest should be fairly straightforward since you know the correct right, up and look vectors. Once you determine the precise look vector and right vector then you can cross them to get the up vector. Then you can take the dot product of those vectors with the 'level' or reference vectors to determine the angles on x, y and z.