|
[Sponsors] |
May 8, 2017, 09:43 |
Rotation of a slice
|
#1 |
New Member
Join Date: Jan 2017
Location: Germany
Posts: 19
Rep Power: 9 |
Hi all,
I am working on a python script to rotate a slice in the x-y-plane and can't find a way to compute the parameters for the Transform filter. The slice is computed by a script and is defined by the origin and the normal. It looks like this: https://www.pic-upload.de/view-33136320/slice.png.html The origin is (12.65, 10.55, 3.0) The normal is (9.28454496846, -68.7942219477, 21.4027743404) or (0.127811549959, -0.947024993173, 0.294631753216) if it is normalized. Now I want to rotate the slice in the x-y-Plane, so that the normal of the rotated slice points in z-direction. I tried to rotate the normal-vector with the rotation matrices ( https://en.wikipedia.org/wiki/Rotation_matrix ), but it does not work. The computed vector shows somewhere, but not in z-direction, when I set it in a Transform filter. What is the right way to compute the rotation parameters of the Transform filter out of the data of the Slice filter? |
|
May 17, 2017, 12:28 |
|
#2 |
New Member
Join Date: Jan 2017
Location: Germany
Posts: 19
Rep Power: 9 |
The Transform filter needs the rotation angles in degrees.
My Slice: sliceclip0.zip The Slice is defined by the Origin (12.65, 10.55, 3.0) and the Normal (9.28454496846, -68.7942219477, 21.4027743404) The angles of the normal vector to the three axes are: to x: 82.65685160236063 ° to y: 161.26691656998636 ° to z: 72.86454299732682 ° To set the slice in the xy-Plane, so that the normal shows in z-direction, it requires rotations around x and y axis, right? When setting the angles to x and y in the transform filter, the slice is still not in the xy-plane. What is the problem with this method? |
|
May 29, 2017, 04:38 |
|
#3 |
New Member
Join Date: Jan 2017
Location: Germany
Posts: 19
Rep Power: 9 |
If anybody else faces the same problem, here is a working solution:
Tho normal of the slice is a numpy array 'normal' with normal[0] = x normal[1] = y normal[2] = z First transform filter: rotation angle around the x-axis = degrees(atan(normal[1] / normal[2])) Then the normal has to be rotated also: angle = atan(normal[1] / normal[2]) # rotation angle from the above Rotation matrix around the x-axis = rotX = np.array([(1.,0,0), (0.,cos(angle),-sin(angle)), (0.,sin(angle),cos(angle))]) new_normal = numpy.dot(rotX, normal) Second transform filter: rotation around the y-axis = degrees(-atan(new_normal[0] / new_normal[2])) It works. It is not possible to calculate both angles at once and put them in one transform filter. Between the calculation of the angles the normal has to be rotated. There may be an issue with the sign (+/-) of the calculation formulas. |
|
January 16, 2018, 07:01 |
How did you find the angles of the normal vector to the three axes? Thank you.
|
#4 | |
New Member
Joao
Join Date: Nov 2017
Location: Campinas - SP
Posts: 3
Rep Power: 9 |
Quote:
Thank you |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Java Macro -- Passive Pith in Superposing Rotation Motion | Weidong Dai | STAR-CCM+ | 2 | August 4, 2018 06:39 |
Remeshing for Rotation in CFX via ICEMCFD | gera | CFX | 3 | September 23, 2017 13:29 |
Fluent rp var to modify rotation speed of a boundary | QBeast | FLUENT | 2 | August 12, 2015 16:58 |
Extracting a non-uniform slice from a 3D geometry | APSK | Visualization & Post-Processing | 1 | October 30, 2014 16:56 |
Mesh motion with Translation & Rotation | Doginal | CFX | 2 | January 12, 2014 07:21 |