MadisonCooper
MadisonCooper

Reputation: 236

Finding Rotation angle between points and axis

I have file1 which contains a set of points in 3D space that resembles a rectangle. I also have file2, which is that same set of 3D coordinates but rotated by some amount about each of the X,Y and Z axis.

How can I find the amount of rotation about each axis? I'm having problems even coming up with a plan of attack for this problem, or else I'd show some example code. Thanks for any help.

Upvotes: 0

Views: 1613

Answers (2)

Michael Fox
Michael Fox

Reputation: 501

I don't have enough reputation to comment and I don't feel this is a complete answer to your question but I wanted to at least help you head in the right direction. This is definitely something related to matrix math which I am no expert in but have done a couple projects with. Reading up on the following might open up some directions for you. Numpy is a package you should look into and will allow you to do the matrix math you'll need.

A wiki about what Singular Value Decomposition is: https://en.wikipedia.org/wiki/Singular_value_decomposition

This is a step in something called Procrustes Analysis that analyzes the relationship between sets of points. Procrustes Analysis with NumPy?

Anyways, looking into matrix math is at least a starting point. I know this isn't a full answer but hopefully this helps in some way.

Upvotes: 1

Damon Tarlaei
Damon Tarlaei

Reputation: 44

This problem can has a basis "How do I calculate what the affine transformation is, if I have the coordinates before and after the transformation?"

There is a good explanation in maths.stackexchange which gives you the exact maths that you need to create the transformation matrix.

The question is then how do you implement this in code? You are using python, so numpy will be your friend here, and in particular, you need the numpy inverse matrix method which will find the inverse matrix needed.

From here, you can use the method and code described in this SO question to get to your final result of the specific angle. This basically says, now that we know the affine transformation, let's apply that to the base unit vectors, and see what the rotation is. NOTE (edit): the numpy implementation of the angle between two vectors can be found here

Upvotes: 2

Related Questions