rotating objects around given line
if one wants to rotate objects around specified line in the space, one will have to gine two different points lying on that line. what is equivalent to giving normalized vector in the space. in OpenGl there are two ways of doing this :
1. transform coordinate system, so that one of its axis coincides with rotatation line. aftewards one will rotate object around selected axis, one that is coincide with rotation line
2. transform whole object, so that rotation can be realized without transforming the coordinate system
[read more]
connecting points using gluCylinder function
how to connect two points with cylinder ? drawing cylinders is very easy while using OpenGl and its quadrics. one simply call funciton gluCylinder with proper parameters. as one can read in OpenGl manual reference, this function draws cylinder along Z axis. The bottom of cylinder is placed in (X,Y,0) plane and the top of cylinder is in plane (X,Y,height). Where height is height of cylinder and is given as one of parameters. if we have two points p1=(x1,y1,z1) and p2=(x2,y2,z2) and we want to connect them with cylinder, we would like to use gluCylinder function. to do this we have to transform our coordinate system, so its Z axis coincide with direction given be vector n=p2-p1.
to do this we have to
0. remember current coordinate system
1. translate cooridinate system do point p1
2. rotate aroud Y axis, so the Z axis coincide with projection of vector n on the XY plane (we get new coorindate system X'YZ')
3. rotate around X' axis, so the Z' axis conicide with vector n direction
4. use gluCylinder function to draw cylinder with height equal |p2-p1|
5. restore saved coordinate system
its easy to show that points 1-3 can be realized using single matrix, given below
where n=p2-p1. when one calculates given matrix, we can set it as a current transformation matrix using function glLoadMatrix*.
SRTM
: Heart surface :
Lets take equation
previous (newer) , 1 , ... , 7 , 8 , 9 , 10 , 11 , next (older)