# Inverting normals numerically

Say i have a set of models, some of them have the normals at their points ok, and some of them have them inverted. and I know which ones have them ok and which ones inverted. So when I detect that Im dealing with one of the ones that have them inverted, I could just invert the normal numerically. If I get the normal doing this:
const normal=pickInfo.getNormal();
what would be the command to properly invert that normal vector to point in the opposite direction? thank you You have to update the mesh geometry. Basically, get the normals vertices data, update the the array and update the vertices data.

Note: the mesh must be updatable to do so.

Some documentation here:

@Cedric thank you Cedric, but isn’t there really a way to do this without having to change the normal vertices data? example, to calculate the steepness at a point I use:
const steepness=Math.acos(normal._y);
and when the normal is inverted, I simply do:
const steepness=Math.acos(-normal._y);

and this works indeed, by using -normal._y I get the correct value of the steepness when the normal is inverted

that’s why I was looking for the generic way to do this for all purposes, maybe it is enough with putting a minus to the 3 coordinates of the normal, that is what I’m trying to confirm, because in the case of the steepness at a point it is working for me to just put a minus to const steepness=Math.acos(normal._y);

Yes, inverting the direction of a vector is simply taking the negate of each 3 coordinates.

In your case you only need to negate y because your are doing a dot product of your normal with (0,1,0), which is `0*normal.x + 1*normal.y + 0*normal.z = normal.y`.

You should normally take the negate of all the components, but negating x and z is superfluous as they are multiplied by 0.

3 Likes