[vtkusers] Rotation matrix 4x4
Oldřich Švec
oldrich.svec at centrum.cz
Fri Feb 10 04:06:58 EST 2012
I try to rotate a sphere by a rotation matrix. For that I have 3 vectors (R1, R2, R3) representing 3 axes of the rotated coordinate system. I create the rotation matrix in the following way:
R1X R2X R3X 0
R1Y R2Y R3Y 0
R1Z R2Z R3Z 0
0 0 0 1
When I rotate the sphere, the sphere becomes black. See the code bellow. Do you have any idea why it becomes black?
open Kitware.VTK
let sphereSource = vtkSphereSource.New()
let fil = new vtkTransformPolyDataFilter ()
let tr = new vtkTransform ()
let mat = vtkMatrix4x4.New ()
mat.SetElement(0,0,-0.404)
mat.SetElement(1,0,0.0763)
mat.SetElement(2,0,0.912)
mat.SetElement(0,1,-0.777)
mat.SetElement(1,1,0.498)
mat.SetElement(2,1,-0.385)
mat.SetElement(0,2,0.484)
mat.SetElement(1,2,0.864)
mat.SetElement(2,2,0.142)
mat.SetElement (3,3,1.)
tr.SetMatrix mat
fil.SetTransform tr
fil.SetInputConnection (sphereSource.GetOutputPort())
let mapper = vtkPolyDataMapper.New()
mapper.SetInputConnection (fil.GetOutputPort())
let actor = vtkActor.New()
actor.SetMapper mapper
let renderer = vtkRenderer.New()
let renderWindow = vtkRenderWindow.New()
renderWindow.AddRenderer renderer
let renderWindowInteractor = vtkRenderWindowInteractor.New()
renderWindowInteractor.SetRenderWindow renderWindow
renderer.AddActor actor
renderer.ResetCamera()
renderWindow.Render()
renderWindowInteractor.Start()
More information about the vtkusers
mailing list