Normal Patch Algorithm

I am trying very hard to reproduce the MATLAB algorithm called "patchnormal" , which first computes the normal vectors of all the faces, and then calculates the vertex normal from the normal of the faces, weighted by the corners of the faces. (See illustration below)

It seems that in WPF C # there is no free library for a three-dimensional grid focused on such mathematical use. Or is there?

So the question is: How do I calculate this (red) vector for all my vertices? Is it possible to optimize it for use in real-time simulation?

PatchNormal Illustration Image
(source: hostingpics.net )

+7
source share
1 answer

You can calculate the angle between two edges as follows:

given: edge vectors E and F for a given face of your vertex, E_normalized = normalize(E) F_normalized = normalize(F) cross_normal = cross(E_normalized, F_normalized) sin_theta = length( cross_normal ) cos_theta = dot(E_normalized, F_normalized) results: face normal = normalize(cross_normal) face angle theta = atan2(sin_theta, cos_theta) 

Then the weight normals, respectively:

 total_vector = vec(0,0,0) for(each face adjacent to a particular vertex): [compute normal and theta as above] total_vector += normal * theta return normalize(total_vector) 

To optimize for real time, I would first profile to see what actually slows down. I would suggest that calculating atan2() several times per vertex can be expensive, but an improvement on this would really require some sort of replacement for angular weighted normals.

+2
source

All Articles