# [vtkusers] polyhedron translate rotate transform

George george.gerber at gmail.com
Mon Nov 3 13:51:06 EST 2014

```Good day,

Is there a way to rotate a polyhedron around more than one axis around its
centre and then to translate it?
Any advice would be greatly appreciated.
Best regards,
George

Below a simple python script for generating a cube polyhedron:
===========
import vtk

# Create polyhedron (cube)
pointIds = vtk.vtkIdList()
pointIds.SetNumberOfIds(8)

for i in range(8):
pointIds.InsertNextId(i)

points = vtk.vtkPoints()
points.InsertNextPoint(-1.0,-1.0,-1.0)
points.InsertNextPoint( 1.0,-1.0,-1.0)
points.InsertNextPoint( 1.0, 1.0,-1.0)
points.InsertNextPoint(-1.0, 1.0,-1.0)
points.InsertNextPoint(-1.0,-1.0, 1.0)
points.InsertNextPoint( 1.0,-1.0, 1.0)
points.InsertNextPoint( 1.0, 1.0, 1.0)
points.InsertNextPoint(-1.0, 1.0, 1.0)

# List of pointIds that make up the face
faceList = [[0, 3, 2, 1],[0, 4, 7, 3],[4, 5, 6, 7],[5, 1, 2, 6],[0, 1, 5,
4],[2, 3, 7, 6]]
faceId = vtk.vtkIdList()
faceId.InsertNextId(6) # Number faces that make up the cell.

for face in faceList: # Loop over all the faces
faceId.InsertNextId(len(face)) # Number of points in face
[faceId.InsertNextId(i) for i in face] # Insert the pointIds for the
face

ugrid = vtk.vtkUnstructuredGrid()
ugrid.SetPoints(points)
ugrid.InsertNextCell(vtk.VTK_POLYHEDRON, faceId)

writer = vtk.vtkXMLUnstructuredGridWriter()
writer.SetInputData(ugrid)
writer.SetFileName("polyhedron.vtu")
writer.SetDataModeToAscii()
writer.Update()

--
View this message in context: http://vtk.1045678.n5.nabble.com/polyhedron-translate-rotate-transform-tp5729337.html
Sent from the VTK - Users mailing list archive at Nabble.com.
```