PDA

View Full Version : Smooth interpolation from a bunch of transformation matrices


vijaykiran
09-16-2009, 11:17 AM
Hello,

I was wondering what is the easiest way in Vizard 3.0 to do a smooth view interpolation if I have a bunch of 4x4 transformation matrices stored in a text file.

On a similar token, is there any sample code/example that comes with vizard that illustrates quaternion usage?

Thanks,
Vijay.

farshizzo
09-17-2009, 05:54 PM
You can use the vizmat.Interpolate function to linearly interpolate between the position values of the matrix:pos = vizmat.Interpolate(pos1,pos2,0.5)

You can also use the vizmat.slerp function to perform spherical linear interpolation between quaternion values of the matrix:quat = vizmat.slerp(quat1,quat2,0.5)

Viewpoint objects have a setQuat method that allows you to specify the rotation as a quaternion. Is this the usage you are looking for?

vijaykiran
09-21-2009, 11:11 AM
farshizzo,

Thanks for the reply. I was sort of looking for this, but I would need to extract the position and quat info before using them.

Given a 4 x 4 transformation matrix, are there any routines that directly extracts the 'pos' and 'quat'?

Thanks,
Vijay.

farshizzo
09-22-2009, 11:01 AM
If you have a list of 16 values representing the 4x4 matrix, then you can initialize a viz.Matrix object with it:matrix_data = [1,2,3,...,16] # 4x4 matrix values

m = viz.Matrix(matrix_data) #Create matrix object
print m.getPosition() #Print position
print m.getQuat() #Print quaternion