Vtktransform and vtktransformfilter in the vtk class: Perform homogeneous coordinate transformation for the point coordinates in the visual Pipeline

Source: Internet
Author: User

Vtktransform

Description vtktransform, a 4x4 matrix linear transformation, can be used to describe the complete linear range (also known as affine) Coordinate Transformation in three dimensions, internally expressed as a 4x4 homogeneous transformation matrix. When you create a new vtktransform, it is always initialized to identify conversion. The setinput () method allows you to set another type of conversion, replacing the ID conversion. There is an MPS queue mechanism to ensure that the current conversion is updated when the input is modified. This pipeline mechanism also supports the concatenate () method. In postmultiply mode, an extra conversion will occur after any conversion is indicated by the current matrix. This class executes all businesses in the right-hand coordinate system using the right-hand rotation. The remaining graphics libraries use the left-hand coordinate system and rotation. Vtktransformfilter is a filter to convert the coordinates of points and the associated point normal vector. Data from other points is filtered. One alternative is to use the vtkactor method to scale, rotate, and move objects. The difference between the two methods is that the conversion of vtkactor only affects the rendering of objects there (through the graphic pipeline), while vtktransformfilter actually modifies the coordinate of vertices in the visual pipeline. This is necessary for some objects (e.g., vtkprobefilter) that need to be used as the coordinates of the Input Point ). Basic Method: Identity () resets vtktransform to the standard status. Elements: 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1

Getposition () from this matrix, return the position point, such as the original matrix rotatey (90), and obtain the position (0.0, 0.0, 0.0)

Getorientationwxyz () from the matrix, Return angle + direction, such as the original matrix rotatey (90), (90.0, 0.0, 1.0, 0.0)

Rotatex, rotatey, rotatez this method, respectively around the X, Y, Z axis, clockwise rotation of a certain angle. For example, rotatez (30), getorientationwxyz () = (29.999999999999993, 0.0, 0.0, 1.0)

Translate (Double X, Double Y, Double Z) translation matrix.

TF. Translate (3, 4, 5)
TF. rotatez (90)

Print TF. getposition (), Tf. getorientation (), Tf. getorientationwxyz ()

Results: (3.0, 4.0, 5.0) (90.0, 0.0, 0.0, 1.0)

  

Example:
#-*-Coding: UTF-8-*-# features # Name: module 2 # purpose: # Author: ankier # created: 18-12-2012 # copyright: (c) administrator 2012 # licence: <your licence> # revoke from actorfactory import actorfactoryfrom VTK import * ##@ detal class transformactorfactory (actorfactory): def _ init _ (Self ): actorfactory. _ init _ (Self) self. _ elevationfilter = vtkelevationfilter () self. _ elevationfilter. setlowpoint (0, 0,-0.5) self. _ elevationfilter. sethighpoint (0, 0, 0.5) def _ makeactors (Self): sphere = vtkspheresource () sphere. setthetaresolution (8) sphere. setphiresolution (8) sphere. setradius (20) transform = vtktransform () transform. scale (0.5, 1.5, 2.0) transformfilter = vtktransformfilter () transformfilter. setinput (sphere. getoutput () transformfilter. settransform (Transform) self. _ elevationfilter. setinput (transformfilter. getoutput () polydatamapper = vtkpolydatamapper () polydatamapper. setinput (self. _ elevationfilter. getoutput () actor = self. _ newactor () actor. setmapper (polydatamapper) # actor. getproperty (). setcolor (0.5, 0.7, 0.2) return [Actor] def _ del _ (Self): del self. _ earthsource

Running result:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.