normal to closest axis direction

Posted By: Wjbender

normal to closest axis direction - 12/15/15 19:03

given that I have a normal that is not facing true to any axis , how can I change it to face in the direction of the axis closest to it ?

I want to let a normal face directly upward if the normal is closest to the upwards axis , and I want it to face directly left or right or forward or backwards if it closer to one of those direction , how would I do such ?

or I guess the question could be thrased as , how to determine in which direction a normal faces ?
Posted By: Superku

Re: normal to closest axis direction - 12/15/15 19:11

I can think of two ideas right know:
1) You compare the absolute values of the normal and choose the direction then.
2) You use vec_dot with the 3 default directions and take the direction which results in the biggest dot product.
Posted By: Wjbender

Re: normal to closest axis direction - 12/15/15 19:51

thanks superku , I will try it , currently I have a rather expensive way of trying to do it .

I had the triangle vertices of a face , and I aligned them planar , then I calculated the face normal for the planar triangle and used the resulting normalized normal to determine direction , but at a larger cost .
© 2024 lite-C Forums