[vtkusers] Rotation matrix 4x4

Oldřich Švec oldrich.svec at centrum.cz
Fri Feb 10 04:25:48 EST 2012


The same result.

I have just figured out that the matrix has determinant = -1, i.e. I had a left handed coordinate system. When I made one of the axis opposite, the colour is fine again. It would be interesting to know, what kind of transformation happened that it lead into a black sphere.

______________________________________________________________
> Od: "Jothybasu Selvaraj" <jothybasu at gmail.com>
> Komu: "Oldřich Švec" <oldrich.svec at centrum.cz>
> Datum: 10.02.2012 10:17
> Předmět: Re: [vtkusers] Rotation matrix 4x4
>
> CC: vtkusers at vtk.org
>Can you try mapper.ScalarVisibilityOff() ?
>
>Jothy
>
>On Fri, Feb 10, 2012 at 9:06 AM, Oldřich Švec <oldrich.svec at centrum.cz>wrote:
>
>>
>> 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()
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>
>
>
>-- 
>Jothy
>



More information about the vtkusers mailing list