I have object (point) in 3d space that i want to move.
For example if this point position in 3d space is (2,3,5) and I need to move it to (7,11,22). I know that I can use glTranslate and just draw it at (7,11,22) but that is to fast and i would like point to “travel” to final destination. I know that i can use normalized vector but not sure how to implement this. Would anyone help me with little example just to get me started please…\
Would be much appreciated
- Well, how about finding the intermediate points on the line segment? i.e Say your initial point is A(0, 0, 1) and final point is B(10, 1 15).
So, find the unit vector along that direction, given by
(10i + 1j + 14k) / |ABvector|.
Now, you can multiply this by an arbitrary number(say 1.5) to obtain a vector along that line in 3D space. this can be considered as an intermediate point for translation.
So, you can use glTranslate to move the object to that intermediate place, so that it will give a “travel” effect.
- Alternatively, you can split the lines into two planes(i mean taking the top view and side views) and then finding slopes, then intermediate points can be found out.
But i feel the first approach is simpler. Please correct me if im wrong.
yeah that worked great.