How to flip surface normals outwards?

353 Views Asked by At

Please what’s the quickest way to simply flip the surface normals of a concave/convex polytope outwards e.g. I am hoping that there's a general way to get this over with using the 2-polytope (polygon) below as our scapegoat
I mean how can we make this

unflipped
become this
flipped

where $\vec{n_0}, \vec{n_1}, \vec{n_2}, \vec{n_3}, \vec{n_4}, \vec{n_5}, \vec{n_6}, \vec{n_7}, \vec{n_8}, \vec{n_9}$ are surface normals, $ABCDEFGHIJ$ the polytope (polygon) and $c$ the centroid

Contextually this problem is similar to this

1

There are 1 best solutions below

2
On

Label the vertices $(p_{i})_{i=0}^{n}$, so that $p_{1} = A$, $p_{2} = B$, …, $p_{n} = J = p_{0}$. The $i$th edge has direction vector $(v_{i1}, v_{i2}) = p_{i} - p_{i-1}$ for $1 \leq i \leq n$. If $n_{i} = (n_{i1}, n_{i2})$ denotes the unflipped normal vector on the $i$th edge, then the flipped normal is $$ \operatorname{sgn}(v_{i1}n_{i2} - v_{i2}n_{i1})n_{i} = \frac{v_{i1}n_{i2} - v_{i2}n_{i1}}{|v_{i1}n_{i2} - v_{i2}n_{i1}|} n_{i}. $$ The multiplier, which is $1$ if the direction-to-normal quarter-turn is counterclockwise and $-1$ if clockwise, implements jlandercy's comment