Given three coordinates (each with x, y and z value), how can I use numpy and/or scipy to calculate the tilt (or inclination) of the resulting plane?
a = np.array([32.49, -39.96,-3.86])
b = np.array([31.39, -39.28, -4.66])
c = np.array([31.14, -38.09,-4.49])
I want to use this calculations to filter a LiDAR point cloud dataset for roof segments. So the roofs have angles like between 30 and 60 degree.
I know that I would have to rotate the planes defined by the three coordinates to calculate the desired angles but I have no clue how this can be achieved with numpy/scipy. What I probably need is a rotation like this:
UPDATE:
Paul Panzers answer makes it possbible to calculate the planes angles with each axis. But how am I able to rotate the plane so that I get angles comparable on one axis for multiple triplet point sets? My main goal: I want to build triangles of each roof point using the two nearest neighbor points and calculate those angles. If there are like 50% angles between 30 and 60 degreee the roof gets classified as gable for example.
Take the cross product of two differences of your three vectors, for example
n = np.cross(b-a, c-a)
This will give you a normal vector to your plane. Its angle with any of the coordinate planes will sum to pi/2 with the angle of your plane with the same coordinate plane.
To calculate the angle between the normal vector and a coordinate plane just normalise and take the arc sin of the corresponding component
nn = n / np.linalg.norm(n)
angles = np.abs(np.arcsin(nn))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With