# scale matrix that change vertex order of frontface

How can I determine if a transformation matrix will change the vertex order of front -facing polygon ?

I know that using minus/inverse scale matrix is not a good idea.
but in my project (2.5D fighting like street fighter 4) the selected view of character model will alway facing the camera

The character model and there animation are define as a right-facing so in order to render left-facing player I have to apply scaling matrix with -1 in x axis. (using my own matrix system similiar to OpenGL fixed function)

The problem is doing so will reverse the order of front facing polygon and I have to call glFrontFace(GL_CW); in order to render correct result.

Are there any way to find out from the final transformation matrix if the matrix will change the vertex order of frontfacing polygon so that I can call glFrontFace(GL_CW) in the right situation ?

Simple, if number of inverted axes is pair, no change of frontfacing (keep default GL_CCW).
If impair, need inversion (use GL_CW).

Another way is to compute the “volume” of the transformation matrix
from the transformation matrix you can exctract the bases and then compute
vec3 XcY = cross(xBase, yBase);
float volume = dot(zBase, XcY);
if volume < 0 your matrix invert the triangle order.

I call it volume, because it’s the volume of the solid that have the bases as edge.

The method proposed by Rosario Leonardi is equivalent to compute the determinant of the upper-left 3x3 block of the 4x4 homogeneous matrix.

If det>0, this is an orientation-preserving transformation. If det<0, this is not an orientation-preserving transformation.