# Transform geometry based on input from a table of points

**URL:** https://discourse.paraview.org/t/transform-geometry-based-on-input-from-a-table-of-points/5816
**Category:** ParaView Support
**Tags:** python
**Created:** [November 16, 2020, 5:06pm UTC](https://discourse.paraview.org/t/transform-geometry-based-on-input-from-a-table-of-points/5816 "2020-11-16T17:06:27Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![Lukasz](https://discourse.paraview.org/user_avatar/discourse.paraview.org/lukasz/32/5392_2.png) [@Lukasz](https://discourse.paraview.org/u/Lukasz)
#### Post date: [December 3, 2020, 11:11am UTC](https://discourse.paraview.org/t/transform-geometry-based-on-input-from-a-table-of-points/5816/6 "2020-12-03T11:11:11Z")

</div>

Just to finish this thread and close it. I achieved exactly what I wanted with the help of:

> [@How to speed up point loop in programmable filter](https://discourse.paraview.org/t/how-to-speed-up-point-loop-in-programmable-filter/5934):
>
> Hi, I have written a programmable filter to perform Euler transformations based on a poly data set and a csv input. The code boils down to a loop over the mesh points and a set of standard matrix transformations of the form for i in range(0, numPoints): coord = pdi.GetPoint(i) x, y, z = coord[:3] x : rotate around ZYX with psi, theta, phi y : rotate around ZYX with psi, theta, phi z : rotate around ZYX with psi, theta, phi newPoints.InsertPoint(i, x, y, z) pdo.SetPoints…

The key point is to avoid loops and use numpy dot product with broadcasting.

Programmable Filter

1. Select geometry and Ctrl+TabletoPoints  
TableToPoints should have Keep All Data Arrays ticked

2. Script

```auto
import numpy

#get cog and angles from the cvs file (TableToPoints)
input1=inputs[1]
x_cg=input1.PointData["DX"]
y_cg=input1.PointData["DY"]
z_cg=input1.PointData["Radar_Altitude"]

yaw=float(-input1.PointData["HEADING"]*numpy.pi/180)
pitch=float(input1.PointData["PITCH_ANGLE"]*numpy.pi/180)
roll=float(-input1.PointData["ROLL_ANGLE"]*numpy.pi/180)

#initiliase the geometry class
pdi = self.GetPolyDataInput()
pdo = self.GetPolyDataOutput()

#initialise time (file number actually)
executive = self.GetExecutive() 
outInfo = executive.GetOutputInformation(0)
ts= outInfo.Get(executive.UPDATE_TIME_STEP())
t=float(ts)

# from body to inertial frame
R = numpy.array([[cos(yaw)*cos(pitch),cos(yaw)*sin(roll)*sin(pitch)-cos(roll)*sin(yaw),sin(roll)*sin(yaw)+cos(roll)*cos(yaw)*sin(pitch)] , [cos(pitch)*sin(yaw),cos(roll)*cos(yaw)+sin(roll)*sin(pitch)*sin(yaw),cos(roll)*sin(pitch)*sin(yaw)-cos(yaw)*sin(roll)] , [-sin(pitch),cos(pitch)*sin(roll),cos(roll)*cos(pitch)] ]) 
output.Points = R.dot(inputs[0].Points.T).T
output.Points = (output.Points.T+[x_cg,y_cg,z_cg+1.795]).T

```

1. RequestInformation Script

```auto
def setOutputTimesteps(algorithm , timesteps):
    "helper routine to set timestep information"
    executive = algorithm.GetExecutive()
    outInfo = executive.GetOutputInformation(0)
 
    outInfo.Remove(executive.TIME_STEPS())
    for timestep in timesteps:
        outInfo.Append(executive.TIME_STEPS(), timestep)

    outInfo.Remove(executive.TIME_RANGE())
    outInfo.Append(executive.TIME_RANGE(), timesteps[0])
    outInfo.Append(executive.TIME_RANGE(), timesteps[-1])

setOutputTimesteps(self,(0,0))

```

---

_[View the full topic](https://discourse.paraview.org/t/transform-geometry-based-on-input-from-a-table-of-points/5816)._
