half edge angle

This commit is contained in:
James E McClure 2018-09-14 21:01:01 -04:00
parent b634f4b72d
commit 20aa80c7c7

View File

@ -385,7 +385,7 @@ double DECL::EdgeAngle(int edge)
V.x = nx/len; V.y = ny/len; V.z = nz/len; V.x = nx/len; V.y = ny/len; V.z = nz/len;
dotprod = U.x*V.x + U.y*V.y + U.z*V.z; dotprod = U.x*V.x + U.y*V.y + U.z*V.z;
if (dotprod > 1.f) dotprod=1.f; if (dotprod > 1.f) dotprod=1.f;
if (dotprod < 0.f) dotprod=-dotprod; if (dotprod < -1.f) dotprod=-1.f;
angle = acos(dotprod); angle = acos(dotprod);
/* project onto plane of cube face also works /* project onto plane of cube face also works
W = U - dotprod*V; W = U - dotprod*V;
@ -404,9 +404,10 @@ double DECL::EdgeAngle(int edge)
} }
// determine if angle is concave or convex based on edge normal // determine if angle is concave or convex based on edge normal
W = 0.5*(P+Q)-R; // vector that lies in plane of triangle W = 0.5*(P+Q)-R; // vector that lies in plane of triangle
hypotenuse = sqrt(W.x*W.x+W.y*W.y+W.z*W.z + V.x*V.x+V.y*V.y+V.z*V.z); // hypotenuse of right triangle //hypotenuse = sqrt(W.x*W.x+W.y*W.y+W.z*W.z + V.x*V.x+V.y*V.y+V.z*V.z); // hypotenuse of right triangle
length = sqrt((W.x+V.x)*(W.x+V.x) + (W.y+V.y)*(W.y+V.y) + (W.z+V.z)*(W.z+V.z)); //length = sqrt((W.x+V.x)*(W.x+V.x) + (W.y+V.y)*(W.y+V.y) + (W.z+V.z)*(W.z+V.z));
if (length > hypotenuse){ //if (length > hypotenuse){
if (W.x*V.x + W.y*V.y + W.z*V.z < 0.f){
// concave // concave
angle = -angle; angle = -angle;
} }