I am trying to implement Dual Contouring, following serveral sources, mainly http://www.sandboxie.com/misc/isosurf/isosurfaces.html but now I want to implement finding the feature point as explained in this post https://gamedev.stackexchange.com/a/83757/49583
It begins with
The QEF you are minimizing is simply the total distance to each of the planes that are defined by the intersection point/normal pairs for that cell.
I do have the intersection point, which is just the edge vertices averaged by their densities. I got the normal by averaging the normal of the edge vertices. I do it like this :
//calculate normals by gradient of surface, d(x,y,z) = density function, d0 = density at p0, d1 = density at p1 Vector3 n0 = new Vector3(d((int)(p0.x+1), (int)p0.y, (int)p0.z ).Value - d0, d((int)p0.x, (int)(p0.y+1), (int)p0.z ).Value - d0, d((int)p0.x, (int)p0.y, (int)(p0.z+1) ).Value - d0); Vector3 n1 = new Vector3(d((int)(p1.x+1), (int)p1.y, (int)p1.z ).Value - d1, d((int)p1.x, (int)(p1.y+1), (int)p1.z ).Value - d1, d((int)p1.x, (int)p1.y, (int)(p1.z+1) ).Value - d1); this.normal = Vector3.Lerp(n0,n1,m);
My plane is this :
Vector4 plane = new Vector4(edge.normal.x, edge.normal.y, edge.normal.z, Vector3.Dot(edge.point, edge.normal));
And I have a vertex at (x,y,z),
Basically, you start the vertex in the centre of the cell. Then you average all the vectors taken from the vertex to each plane and move the vertex along that resultant...
How do I get the vector from the plane to the vertex?