[vtkusers] Dealing with 3D vectors & vtkCone

Jean-Marie Normand normand at lina.univ-nantes.fr
Tue Nov 23 09:58:48 EST 2004


Hi Andrew!

Thanks for your answer, the code provided by the link gives the 3x3
matrix that rotates a unit vector f into another unit vector t. 

But my problem is that I want to rotate a vtkCone in order to make its
axis of rotation (the x-axis) coincide with another vector v(vx,vy,vz).

The C-code from Moller&Hughes gives me a 3x3 matrix that could transform
the x-axis of my cone into the v vector. So I tried to transform the 3x3
matrix into a vtkMatrix4x4 and set it as a vtkTransform to my vtkCone,
but this didn't work. The cone wasn't oriented towards v.

In order to transform the 3x3 matrix into a 4x4, I added the following
line and column :

M_00 M_01 M_02 0
M_10 M_11 M_12 0
M_20 M_21 M_22 0
0    0    0    1

Maybe this transformation is wrong, can anyone tell me how to orient the
cone from the original position(0,0,0) and orientation(the x-axis) to a
given position (x,y,z) and a given orientation (vx,vy,vz) ?

Thanks in advance.


Jim

Le mar 23/11/2004 à 00:10, Andrew Maclean a écrit :
> Look at vtkMath.
> I would think that you would need to use a transform matrix.
> 
> Regarding computing rotation angles by projection, quaternions offer a
> better way to do this. In "Real-Time Rendering" Moller, Hains edn2, pp51-53,
> There is a nice method using quaternions for calculating the transform
> rotating one vector to another. Look at:
> http://www.acm.org/jgt/papers/MollerHughes99/ has some c-code to get you
> started.
>  
> 
> Andrew
> 
> 
> -----Original Message-----
> From: Jean-Marie Normand [mailto:normand at lina.univ-nantes.fr] 
> Sent: Tuesday, 23 November 2004 01:44
> To: vtkusers
> Subject: [vtkusers] Dealing with 3D vectors
> 
> Hi,
> I'd like to know if there is a class designed to deal with 3D
> (normalized) vectors. Basically I'd like to rotate a vector ((1,0,0) for
> example) to make it fit another (normalized) vector which X,Y and Z
> components (vx,vy,vx) are known. That is to say (1,0,0) should become
> (vx,vy,vz) after the rotations.
> 
> I should be able to compute the rotation angles by projection on the OXY
> and OXZ planes and then rotate the vector.
> 
> Is there a way to handle the rotations of vectors in 3D or do I need to
> use the transformation matrix ?
> 
> Thanks in advance.
> Jim
> 
> 
> 
> 




More information about the vtkusers mailing list