Orientation of a triangle's vertices in 3D space: Clockwise or counter clockwise?

870 Views Asked by At

Consider the following theoretical framework I’ve come up so far from bits and tips, mainly from Wikipedia and Orientation of three points in 3D space :

Given ${E}$, an Euclidean space $\Bbb R^3$ with a Cartesian frame ${\left\{O=(0,0,0),e_{x}=(1,0,0), e_{y}=(0,1,0),e_{z}=(0,0,1)\right\}}$, where ${O}$ is a point of ${E}$ called the ${origin}$ and ${\left\{e_{x},e_{y},e_{x}\right\}}$ is called the ${standard\ basis}$ and forms an orthonormal basis of ${\overrightarrow {E}}$.

Given ${T}$, an oriented triangle in ${E}$, with noncollinear vertices ${\left\{{A}=( x_1 , y_1 , z_1 ),{B}=( x_2 , y_2 , z_2 ),{C}=( x_3 , y_3 , z_3 )\right\}}$ and considering the vectors: $$\vec{v}_1 = \overrightarrow {AB}=\left({B}-{A}\right ) \text{ and } \vec{v}_2 = \overrightarrow {AC} = \left ( {C} - {A} \right ), $$ which represent the edges of ${T}$ with origin at vertex ${A}$.

Let $\vec{n} = \vec{v}_1 \times \vec{v}_2$, where $\vec{n}$ is a scaled normal (perpendicular) to the plane defined by ${T}$. The direction of $\vec{n}$ is given by the right-hand rule. This alone doesn’t tells much about the direction of $\vec{n}$ or the orientation of ${T}$'s vertices, but as ${T} \in {E}$ then the direction of $\vec{n}$ can be compared to the orthonormal basis of ${\overrightarrow {E}}$, using the dot product.

For the most part of situations the points’ orientation assessment will be made regarding the $xy$-plane, that is to say, the direction of $\vec{n}$ will be compared to $\hat {e_{z}}$

So, the orientation of the three vertices $\left (A,B,C \right )$ of ${T}$ will be: $$\begin{cases} \hat {e_{z}} \cdot \vec{n} \gt 0, \text{ counterclockwise (CCW)} \\ \hat {e_{z}} \cdot \vec{n} \lt 0, \text{ clockwise (CW)} \\ \hat {e_{z}} \cdot \vec{n} = 0, \text{ degenerate case } \end{cases}$$

There are several possible "degenerate cases" but, in this case, it is known that $\hat {e_{z}} \neq 0 \ \land \ \vec{n} \neq 0 $ (noncollinear vertices).

Then, if $\hat {e_{z}} \cdot \vec{n} = 0 \implies \hat {e_{z}}$ and $\vec{n}$ are orthogonal $\implies {T}$ forms a plane parallel to $\hat {e_{z}}$.

$\DeclareMathOperator{\proj}{proj} \newcommand{\vct}{\mathbf} \newcommand{\vctproj}[2][]{\proj_{\vct{#1}}\vct{#2}}$

Now consider this particular case where:

${A} = ( 2 , 1 , 1 ), {B} = ( 0 , -1 , 1 ) \text{ and } {C} = ( 1 , 0 , 0 ) \implies \vec{v}_1 = ( -2 , -2 , 1 ) \text{ and } \vec{v}_2 = ( -1 , -1 , -1 ) \implies \vec{n} = ( 2 , -2 , 0 ) $

3D representation

As we can see, ${T}$ forms a plane parallel to $\hat {e_{z}}$, and so we cannot assert the orientation of vertices $\left (A,B,C \right )$ using $\hat {e_{z}}$.

$xy$-plane

From what I understand, we should then choose the axis of ${E}$'s cartesian frame, $\hat {e_{x}} \lor \hat {e_{y}} $, that is more representative of $\vec{n}$’s direction. That is to say that, considering that: $$\vec{n}=(n_{x},n_{y},n_{z}) = ( 2 , -2 , 0 )$$

we should then choose the component of $\vec{n}$ with the highest absolute value: use $\hat {e_{x}}$ or $\hat {e_{y}}$ if $\left| n_{x} \right|$ or $\left|n_{y}\right|$ is the highest value, respectively. This is the same as choosing the ${x}$ or ${y}$-axis where the projection of $\vec{n}$ has higher magnitude: $$\max({\lVert\vctproj[{e_{x}}]{n}\rVert}, {\lVert\vctproj[{e_{y}}]{n}\rVert})$$

As we can see in this particular case where $\vec{n}=( 2 , -2 , 0 )$, $\left| n_{x} \right| = \left|n_{y}\right|$ , so choosing $\hat {e_{x}}$ or $\hat {e_{y}}$ would be equally right to assert the orientation of ${T}$'s vertices.

If we choose then $\hat {e_{x}}$ then $ \hat {e_{x}} \cdot \vec{n}=(1,0,0) \cdot ( 2 , -2 , 0 )= 2 \gt 0 \implies$ vertices $\left (A,B,C \right )$ are oriented CCW, as can be seen in the following picture.

$yz$-plane

However, if we choose then $\hat {e_{y}}$ then $ \hat {e_{y}} \cdot \vec{n}=(0,1,0) \cdot ( 2 , -2 , 0 )= -2 \lt 0 \implies$ vertices $\left (A,B,C \right )$ are oriented CW, as can be seen in the following picture, which means that that the direction of $\vec{n}$ is opposite to the direction of $ \hat {e_{y}}$.

$xz$-plane

So, my conclusion is that the dot product between a vector of the ${standard\ basis}$ of ${\overrightarrow {E}}$ and $\vec{n}$, or the scalar triple product of ${\left\{\hat {e}, \vec{v}_1,\vec{v}_2\right\}}$, actually compares the directions of ${\left\{\hat {e}, \vec{n}\right\}}$ and a better description of the result would be: $$\begin{cases} \hat {e} \cdot \vec{n} \gt 0, \text{ same direction} \\ \hat {e} \cdot \vec{n} \lt 0, \text{ opposite directions} \\ \hat {e} \cdot \vec{n} = 0, \text{ degenerate case, possibly orthogonal } \end{cases}$$

and that, in $\Bbb R^3$, the orientation of a triangle's vertices (CCW or CW) is a matter of perspective, it depends from where you look at it...

Is this conclusion correct? Is there any way to denote, unequivocally, the orientation of a triangle vertices (CCW or CW) in $\Bbb R^3$?

1

There are 1 best solutions below

0
On

I would approach the issue from a completely different direction.

Consider a triangle in 3D with vertices at $\vec{v}_0$, $\vec{v}_1$, and $\vec{v}_2$. It has a directed normal $\vec{n}$, $$\vec{n} = \left(\vec{v}_1 - \vec{v}_0\right)\times\left(\vec{v}_2 - \vec{v}_0\right) \tag{1}\label{1}$$

If we look along $\vec{n}$ in one direction, the vertices are clockwise; in the opposite direction, counterclockwise. In particular, $$-\vec{n} = \left(\vec{v}_2 - \vec{v}_0\right)\times\left(\vec{v}_1 - \vec{v}_0\right) \tag{2}\label{2}$$

Thus, the order of the vertices – clockwise or counterclockwise – is not a property per se in 3D. It only arises when one somehow, arbitrarily, chooses among the two possible normal directions ("$\vec{n}$" or "-$\vec{n}$"). This is a similar problem to half-spaces: a plane, like the plane of the triangle, divides the space into two; but other than choosing one based on the direction of the plane normal, there is nothing distinguishing between the two.

In computer graphics, surfaces are often directed, i.e. they are only drawn when viewed from one half-space. (This saves resources, because only approximately half the surfaces of each object need to be drawn, and the test is trivial – just calculate the dot product of the surface normal and a vector from the surface to the viewer – even before any projection or transformations are done. The surface is only visible if the dot product is positive, i.e. if the surface normal is towards the viewer.)

This is done by fixing the normal direction per $\eqref{1}$. In practice, it then means that a triangle surface is only visible when its projected vertices are in counterclockwise order on the screen (or clockwise, depending on the programmer choice!). But, that is not the reason, it is a consequence, of how the normal is defined, and of only surfaces with their normals pointing towards the viewer being visible/drawn. (And the reason for defining the normal that way, is to be able to drop about half of all surfaces from being transformed, projected, and drawn on screen, thus up to halving the calculation and rendering time.)