[vtkusers] Rotation matrix 4x4
David E DeMarle
dave.demarle at kitware.com
Fri Feb 10 08:14:20 EST 2012
My suggestion is that it appeared black because of lighting.
Ie the normals were inverted and thus the nearside visible triangles
always had their normals facing away from the camera and thus had a
zero diffuse color term.
David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909
On Fri, Feb 10, 2012 at 4:25 AM, Oldřich Švec <oldrich.svec at centrum.cz> wrote:
>
> 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
>>
> _______________________________________________
> 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
More information about the vtkusers
mailing list