diff --git a/graphicswin.cpp b/graphicswin.cpp index b6d98db..b664461 100644 --- a/graphicswin.cpp +++ b/graphicswin.cpp @@ -649,17 +649,17 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown, double theta = atan2(orig.mouse.y-p2.y, orig.mouse.x-p2.x); theta -= atan2(y-p2.y, x-p2.x); - Vector normal = orig.projRight.Cross(orig.projUp); + Vector normal = projRight.Cross(projUp); u = u.RotatedAbout(normal, -theta); v = v.RotatedAbout(normal, -theta); } else { double dx = -(x - orig.mouse.x); double dy = -(y - orig.mouse.y); double s = 0.3*(PI/180); // degrees per pixel - u = u.RotatedAbout(orig.projUp, -s*dx); - u = u.RotatedAbout(orig.projRight, s*dy); - v = v.RotatedAbout(orig.projUp, -s*dx); - v = v.RotatedAbout(orig.projRight, s*dy); + u = u.RotatedAbout(projUp, -s*dx); + u = u.RotatedAbout(projRight, s*dy); + v = v.RotatedAbout(projUp, -s*dx); + v = v.RotatedAbout(projRight, s*dy); } orig.mouse = mp; normal->NormalForceTo(Quaternion::From(u, v)); diff --git a/polygon.cpp b/polygon.cpp index 699b581..ded6ded 100644 --- a/polygon.cpp +++ b/polygon.cpp @@ -7,6 +7,10 @@ Vector STriangle::Normal(void) { bool STriangle::ContainsPoint(Vector p) { Vector n = Normal(); + if(n.Magnitude() < LENGTH_EPS*LENGTH_EPS) { + // shouldn't happen; zero-area triangle + return false; + } return ContainsPointProjd(n.WithMagnitude(1), p); } diff --git a/solvespace.cpp b/solvespace.cpp index bb960f0..f3ce3b6 100644 --- a/solvespace.cpp +++ b/solvespace.cpp @@ -459,7 +459,7 @@ void SolveSpace::MenuFile(int id) { case GraphicsWindow::MNU_EXIT: if(!SS.OkayToStartNewFile()) break; - exit(0); + ExitNow(); break; default: oops(); diff --git a/solvespace.h b/solvespace.h index 121801d..b93038b 100644 --- a/solvespace.h +++ b/solvespace.h @@ -79,6 +79,7 @@ void dbp(char *str, ...); CO((tri).a), CO((tri).b), CO((tri).c)) void Error(char *str, ...); +void ExitNow(void); void *AllocTemporary(int n); void FreeAllTemporary(void); diff --git a/win32/w32main.cpp b/win32/w32main.cpp index 024e076..8eedc66 100644 --- a/win32/w32main.cpp +++ b/win32/w32main.cpp @@ -67,6 +67,10 @@ void Error(char *str, ...) MessageBox(h, buf, "SolveSpace Error", MB_OK | MB_ICONERROR); } +void ExitNow(void) { + PostQuitMessage(0); +} + //----------------------------------------------------------------------------- // A separate heap, on which we allocate expressions. Maybe a bit faster, // since no fragmentation issues whatsoever, and it also makes it possible