5
$\begingroup$

Say I have a triangle in $3$D space. I can get the surface normal by calculating the vector cross product of two of the edges.

But, lets say I make this a tetrahedron. How can I work out the outward surface normal for each side?

  • 0
    @ShuhaoCao you should post this comment as an answer.2012-08-19

2 Answers 2

4

For a given face $f,$ let its surface normal be $\vec{n}.$ The outward direction normal will be either $\vec{n}$ or $-\vec{n}.$ To determine which, let the $4$th vertex of the tertrahedron (the apex opposite to the $f$) be $v,$ and let one of the vertices of the face $f$ be $p.$

Thanks to Rahul Narain's hint: now, consider the $2$ vectors $\vec{n}$ and $\vec{pv} = v - p.$ If they're both on the same side (with respect to $f$), then $\vec{n} \cdot \vec{pv} $ is positive$^\dagger$ and $\vec{n}$ is facing inwards. If $\vec{n}$ is facing outward, then $\vec{n} \cdot \vec{pv} $ is negative. Based on the sign of $\vec{n} \cdot \vec{pv} $ you can know whether $\vec{n}$ or $-\vec{n}$ is the outward vector you're after.

$^\dagger$ recall the dot product $a\cdot b = \| a \| \| b \| \cos \theta_{ab}.$

2

As Jennifer Dylan said, I will post my more computational geometry-oriented answer here since OP used comp-geom as one of the tags for the question:

In short, the idea is

A specific labeling of each vertex/edge/face would help the automation or parallelization of computing the outward surface normal for computer graphics.

Now suppose locally we have one tetrahedron, and we label it as follows: Local labeling for a tetrahedron

We have four vertices: $V_i$, $i = 1,\ldots,4$, it doesn't matter how we label which vertex is which, but rather we keep this local labeling consistent globally for each tetrahedron(supposedly we have a 3-D triangulated mesh), we label the face opposite to vertex $V_i$ as $F_i$, to characterized $F_i$, we use three vertices that spans $F_i$, now we have the following 4 correspondences(or say pointer to an array): $ \begin{aligned} &F_1 \longleftrightarrow V_2 V_3 V_4 \\ &F_2 \longleftrightarrow V_1 V_4 V_3 \\ &F_3 \longleftrightarrow V_1 V_2 V_4 \\ &F_4 \longleftrightarrow V_1 V_3 V_2 \end{aligned} $ The ordering of $i_1 i_2 i_3$ in $F_i \longleftrightarrow V_{i_1} V_{i_2} V_{i_3}$ follows the rule (a) $i_1$ is the smallest of all three(for sorting purposes in any computation) (b) $V_{i_1} \rightarrow V_{i_2}\rightarrow V_{i_3}$ form a counterclockwise cycle with respect to the outward normal of each face(right hand rule for cross product). $\newcommand{\vn}{\boldsymbol{n}}$


Labeling done, then either

(1) The outward normal $\vn_i$ to surface $F_i$ can be computed by: $\vn_i = (V_{i_2} - V_{i_1})\times (V_{i_3} - V_{i_2})$

this is the common geometrical way to compute a surface normal, can be easily vectorized for computing purposes, say if we have the tetrahedron information stored in an $(\#\text{ of tetrahedron})\times 4$ two-dimensional array, and each vertex's coordinates are stored in an $(\#\text{ of vertices})\times 3$ two-dimensional array.

However, it is not robust when the tetrahedron is not regular, ie we may have two nearly parallel sides.

or

(2) This is where Newell's method for calculating outward surface normal kicks in as J.M. mentioned in his comment, basically what the code in the link does is: $ \begin{aligned} &\vn_{F_i,x} = \sum_{i=1}^{n} (y_i - y_{i+1})\cdot(z_i + z_{i+1}) \\ &\vn_{F_i,y} = \sum_{i=1}^{n} (z_i - z_{i+1})\cdot(x_i + x_{i+1}) \\ &\vn_{F_i,z} = \sum_{i=1}^{n} (x_i - x_{i+1})\cdot(y_i + y_{i+1}) \end{aligned} $ and $i$ is in the additive cyclic group $\{1,2,3,4\}$. If we expand the summation, we will find two algorithms are the same.