0

I have a surface (square, real object) that is a bit tilted (not parallel to the ground). Now, for this surface, I measured the coordinates (x,y and most important z) of 3 of its corners (centimeters), relative to the ground on which the surface stays (let's say that the bottom-left corner is x=0,y=0).

I need to know towards which direction is this plane inclined (relative to an imaginary vertical line that goes through the middle of the surface).

I guess I actually need two angles. One will give the tilt on the x-axis, and the other the tilt on the y-axis.

IceCold
  • 117
  • Vector cross and dot product may help if you know what they are. – Benjamin_Gal Aug 18 '21 at 15:45
  • 1
    Use this formula. Use any vertical vector as $\mathbf v,$ and the cross product of any two vectors parallel to the plane as $\mathbf n.$ – ryang Aug 18 '21 at 15:48
  • Is the tilted surface an (ET) Equilateral Triangle (3-corners) or a (PS) Perfect Square (with one corner touching the reference plane)? If ET or PS, then treat those corners as uniform points distributed locations on a perfect CIRCLE and their locations of elevation. I would venture that you could calculate the low point of the circle (and its direction) from this information. Otherwise you could model this in CAD and extract the information. – Jim Clark Aug 18 '21 at 15:53
  • @JimClark - it is a Perfect Square – IceCold Aug 18 '21 at 16:00
  • See my updated answer below. – Jim Clark Aug 18 '21 at 21:41

4 Answers4

2

Given the three points

$$ \cases{ p_1 =(x_1,y_1,z_1)\\ p_2 = (x_2,y_2,z_2)\\ p_3 =(x_3,y_3,z_3) } $$

we have the normal to the plane as

$$ \vec n = (p_2-p_1)\times(p_3-p_1) $$

and then giving a vertical direction $\vec v = (0,0,1)$ we have

$$ \cos\theta = \frac{\vec n\cdot\vec v}{\|\vec n\|\|\vec v\|} = \frac{x_2 y_3-x_2 y_1 + x_3 y_1 + x_1 y_2 - x_3 y_2 - x_1 y_3}{\sqrt{(x_2 y_1 - x_3 y_1 - x_1 y_2 + x_3 y_2 + x_1 y_3 - x_2 y_3)^2 + (x_2 z_1 - x_3 z_1 - x_1 z_2 + x_3 z_2 + x_1 z_3 - x_2 z_3)^2 + (y_2 z_1 - y_3 z_1 - y_1 z_2 + y_3 z_2 +y_1 z_3 - y_2 z_3)^2}} $$

Here $\theta$ is the angle between the plane and the vertical (or almost). It is necessary to verify also the $\theta$'s complement to $\pi$

Cesareo
  • 33,252
  • @cesareo - So, the angle and the orientation of the tilt cannot be calculated (considering the data I have)? – IceCold Aug 19 '21 at 15:41
  • All we have is the angle between the plane normal $\vec n$ and the vertical direction $\vec v$. Also we have the plane containing the vertical axis and the normal which is the measuring plane. All this assuming that the measured coordinates pertain to a plane surface and don't follow a line. – Cesareo Aug 19 '21 at 16:51
1

Set up the coordinate axes such that the $z$-axis is vertical, and one of the three given corners (whichever one) is the origin $O.$ Let the position vectors of the other two given corners be $\begin{pmatrix}x_2\\y_2\\z_2\end{pmatrix}$ and $\begin{pmatrix}x_3\\y_3\\z_3\end{pmatrix}.$

Then $\begin{pmatrix}x_2\\y_2\\z_2\end{pmatrix}$ and $\begin{pmatrix}x_3\\y_3\\z_3\end{pmatrix}$ are collinear to the given plane; so, $\mathbf n=\begin{pmatrix}x_2\\y_2\\z_2\end{pmatrix}\times\begin{pmatrix}x_3\\y_3\\z_3\end{pmatrix}=\begin{pmatrix}y_2z_3-y_3z_2\\-x_2z_3+x_3z_2\\x_2y_3-x_3y_2\end{pmatrix}$ is normal to the plane.

Noting that $\mathbf v=\begin{pmatrix}0\\0\\1\end{pmatrix}$ is a vertical vector, using this formula, the angle between the plane and the vertical҂ is $$\theta=\arcsin\left|\frac{\mathbf v \cdot\mathbf n}{\left|\mathbf v\right| \,\left|\mathbf n\right|} \right|\\ =\arcsin\left|\frac{x_2y_3-x_3y_2}{\sqrt{\left(y_2z_3-y_3z_2\right)^2+\left(-x_2z_3+x_3z_2\right)^2+\left(x_2y_3-x_3y_2\right)^2} } \right|.$$

$\large҂$

  1. which direction is this plane inclined (relative to an imaginary vertical line that goes through the middle of the surface)

    The above angle $\theta$ is made with the vertical, i.e., is independent of the location of the imaginary vertical line.

  2. I guess I actually need two angles. One will give the tilt on the x-axis, and the other the tilt on the y-axis.

    You just need one angle to fully specify the plane's tilt; the angle that the plane makes with the horizontal is simply $(90^\circ-\theta).$

ryang
  • 38,879
  • 14
  • 81
  • 179
  • I marked the bottom right corner as being x2,y2,z2 and the top right corner as x3,y3,z3 and I am getting weird results (35 deg) for x1= 00; x2= 10; x3= 10; y1= 00; y2= 00; y3= 10; z1= 10; z2= 10; z3= 00; I think for these points, only the bottom edge should be "in the air". This cannot lead to that 35 degree angle. – IceCold Aug 23 '21 at 15:09
  • Sorry about the change in the question. Your original post did not include an answer about how to determine the direction of the inclination. So, I thought the question was not fully understood. Anyway, I think the question remains the same (as your answer also) :) – IceCold Aug 26 '21 at 12:19
  • However, I still don't get how I can determine in which direction is the plane inclined, if I only get one angle from the formula. Let's say the surface is inclined 45 degree to the "north". The formula will output 45. If I reset the plane and then incline it to the "east" (also 45 deg), the formula will still output 45. So, my plane was inclined in two directions, but I only get one number. How do I make a distinction between the two results? – IceCold Aug 26 '21 at 12:23
0

If you know three points in the plane then you can calculate two vectors in the plane (if the three points are $(x_0, y_0, z_0)$, $(x_1, y_1, z_1)$, $(x_2, y_2, z_2)$ then $<x_1-x_0, y_1-y_0, z_1-z_0>$ and $<x_2-x_0, y_2-y_0, z_2-z_0>$ are vectors lying in the plane). The angle between either of those vectors and the given line is the angle between the plane and the line.

user247327
  • 18,710
-1

@Gravity, from the comments in the original problem, you indicate this is a perfect square part with one corner resting on the horizontal plane of Z reference.

Using the calculation that follows, we come up with two-equations and two-unknowns, which we then solve. (At the time, the X and Y locations of the the corners relative to the ground were unknown.)

Imagine a perfect circle canted at an angle, reletive to the ground's vertical, and a perfect square randomly placed on the circle such that the four corners, of the square, lie on the periphery of the circle. This is what you have (the circle is imaginary and for calculation purposes). The two diagonals of the square both represent the DIAMETER of the imaginary circle. The DIAMETER will be used at the end (along with the calculated HEIGHT) to calculate the CantedAngleOfTheCircle (the flagpole normal of the square off of the ground's vertical in degrees).

I am trying to solve this in terms that you know (or can measure), since you don't know the X, and Y locations of each corner (reletive to the ground's plane of reference), just the Z locations (reletive to the ground's plane of reference).

What I visualize is:

  1. The elevation difference between the highest point and the lowest points of the imaginary circle is one variable, $HEIGHT$.

  2. The other variable is the $ANGLE$ between two lines (described below), $$( 0º < ANGLE < 90º )$$ The line between the two opposite corners of the square with the largest height difference and the line between the highest and lowest points of the imaginar circle (as measured in the plane of your square part).

Let’s call the shortest elevation difference across one diagonal of the square $MIN$. And let’s call the longest elevation difference across the other diagonal $MAX$. Both $MIN$ and $MAX$ are known numerical values.

Since we are referencing $ANGLE$ relative to the largest elevation difference, $MAX$, I will use the cosine in my function.

Angles are measured in degrees.

$$MAX = HEIGHT · COS ( ANGLE )$$ $$MIN = HEIGHT · COS ( 90 + ANGLE )$$

Let’s solve the second equation for $HEIGHT$ and place it into the first equation and then the first equation becomes,

$$MAX = MIN · COS ( ANGLE ) / COS ( 90 + ANGLE )$$

Then we'll solve for $ANGLE$.

Since $SIN ( 90 + ANGLE ) = COS ( ANGLE )$ we can say,

$MAX = MIN · TAN ( 90 + ANGLE )$

Thus $ANGLE = ARCTAN ( MAX / MIN ) - 90$

Let’s set $MIN$ as $10-mm$ and $MAX$ as $15-mm$.

Then $ANGLE = -33.7º$ and $HEIGHT = 18.0-mm$.

Finally (to answer your original question), use the value $HEIGHT = DIAMETER \cdot SIN(CantedAngleOfTheCircle)$ in order to calculate the circle's normal angle relative to the vertical. Do this by using,$$CantedAngleOfTheCircle = ASIN (HEIGHT / DIAMETER )$$

Use the values you know (DIAMETER (from the hypotenuse of the square)) or have measured (MIN, MAX) and see if this algorythm provides an answer that solves your concern.

Jim Clark
  • 212
  • Hi. How will the final formula give the orientation of the tilt? – IceCold Aug 19 '21 at 15:49
  • The normal of the square plate is the direction of the tilt while the CantedAngleOfTheCircle that is calculated (at the end) is the angular value off of the vertical. – Jim Clark Aug 19 '21 at 17:23
  • Think of the square's normal as a flagpole orthogonal to the plane of the square. That is the direction of tilt. – Jim Clark Aug 19 '21 at 18:06