Hello Again.
in the last video you saw when I want to change the camera view point in order to look at the robot from another place I had to move location along with each individual axis.
This was ugly and unprofessional, in all programs they rotate the camera using the mouse wheel button, and the mouse pointer location.
but there is a problem arises in here that the mouse moves in two coordinate plane and the camera is placed in a 3 coordinate system, this what we are goint to talk about here. but first we need to establish some rules.
This is not a tutorial explaing how to use directx we'll use it to ilustrate things up, using it as a tool studing it is beyond the scope of this script.
The same thing is applied on the programming language I'm using here, you can apply it on any programming language ( but if you don't know any language it is really a shame.)
The videos are going to be without any commentary this time. ( I've listened to video I made last time and my accent sounded outfall
, although it kinda sounded nice when I was hearing the words straight from my mouse
)
before you continue with me you should've studied linear algebra ( specifically Matrices )
and lastly take a look at:
http://en.wikipedia.org/wiki/Rotation_matrixhttp://www.fastgraph.com/makegames/3drotation/this is about rotating objects in space.
now to answer the previous question how to use 2 coordinate sytem to control 3 coordinated sytem.
direct x uses transformation matrices in order to manipulate every thing in the 3d world
I will asume that you've read the previous links about transformation matrix.
the first matrix that direct x uses is "the world matrix" this one represent the base coordinate sytem where every thing is placed with respect to. If this matrix is "I" ( identity matrix ) every thing will be rendered (drawed ) without altering its position or it's orientation "compounded pose"
the other matrix will represent the camera ( or your eye ) this matrix holds information about the camera postion and orientation " where the camera is looking, witch way is up, so not to draw every thing fliped upside down )
and what directx does actualy is that it will multiply those two matrices to generate one matrix that directx will use to draw every thing with respect to it.
but first it has to reverse what ever this matrix tells you
for example if you're holding a camera taking a photo of a car
if you maved the camera right then you can imagine that the car is moved left.
you see the car is moved left or the camera is moving right
it's now obvious to manipulate the camera matrix to change the way you look at the scene.
back to our problem how to use 2 coordinate mouse to control 3 coordinate camera matrix
one of the solutions "I'm using now" is to rotate around y "yaw rotation" using the mouse movement on x Axis.
each step positive you can rotate like 5 degrees clockwise or more depending on the speed you want.
but this will leave us with 2 other axis ( x,z) and only one mouse axis to control them.
if you assigned this direction of mouse to control for example the x axis of the world "graphics world, not the world we live
"
you will get the results in the next video
After couple of rotations and you'll be lost then you will foget how to go back to the orginal pose.
the solution for this particular prblom is not to rotate around the the world's X axis, use the camera X axis instead, now you will gain control over the world's X,Z axis.
the axis of rotation depends on the order of rotation matrix multiplication.
if you pre-multiplied the camera matrix by the rotation matrix ( C * R ) then you will get a rotation around the camera's X axis
but if you post-multiplied the camera matrix by the rotation matrix ( R * C ) then you will rotate around the World's X axis
and what we're going to do is that when we rotate around Y "yaw rotation " we will Post-multiply and in the case of x we'll pre-multiply
look at the results yourself in the next video
oops the rotation is around the x but the camera is filming the sky.
imagine that you're holding the camera, in the yaw rotation you can move around the object but in the pitch case "rotaion around X" you have to evovle 2 wings and fly
in mathimatics you have to rotate the vector connects the worlds's coordinate system's origin to the camera's origin
then you have to multiply the Rotation matrix to this vector and then you will rotate that vector with the camera "fly with the camera
"
here's the final result
-------------------------------------
finally: I know all of the stuff in here are not electronics but this really important in robotics "Transformation matrices I mean"
If there's any one interested of what I'm saying please let me know.
the purpose of writing this thread in here, is to share every step I'm taking as my project is evolving with people who have the same interest I do. and first I thought it's going to be a couple of chips and a software on a microcontroller then I'm done.
so please tell me should I continue.or you really guys want to stick to electronics