Oops, was computing numerical by perturbing a point in uv; but the

xyz point that I subtracted off had been refined to lie exactly on
our edge's curve, and the uv point that I started with had not. So
normals got randomly screwed up.

[git-p4: depot-paths = "//depot/solvespace/": change = 1978]
This commit is contained in:
Jonathan Westhues 2009-06-10 00:04:35 -08:00
parent 1ac083a9a2
commit 2013f9f466
3 changed files with 9 additions and 5 deletions

View File

@ -57,7 +57,7 @@ void SolveSpace::Init(char *cmdLine) {
lightDir[1].y = CnfThawFloat( 0.0f, "LightDir_1_Up" );
lightDir[1].z = CnfThawFloat( 0.0f, "LightDir_1_Forward" );
// Chord tolerance
chordTol = CnfThawFloat(1.5f, "ChordTolerance");
chordTol = CnfThawFloat(2.0f, "ChordTolerance");
// Max pwl segments to generate
maxSegments = CnfThawDWORD(10, "MaxSegments");
// View units

View File

@ -276,7 +276,6 @@ void SSurface::EdgeNormalsWithinSurface(Point2d auv, Point2d buv,
Point2d enuv = abuv.Normal();
*pt = PointAt(muv);
*surfn = NormalAt(muv.x, muv.y);
// If this edge just approximates a curve, then refine our midpoint so
// so that it actually lies on that curve too. Otherwise stuff like
@ -288,8 +287,11 @@ void SSurface::EdgeNormalsWithinSurface(Point2d auv, Point2d buv,
double t;
sc->exact.ClosestPointTo(*pt, &t, false);
*pt = sc->exact.PointAt(t);
ClosestPointTo(*pt, &muv);
}
*surfn = NormalAt(muv.x, muv.y);
// Compute the inner and outer normals of this edge (within the srf),
// in xyz space. These are not necessarily antiparallel, if the
// surface is curved.
@ -487,7 +489,6 @@ void SShell::MakeIntersectionCurvesAgainst(SShell *agnst, SShell *into) {
// list for into.
sa->IntersectAgainst(sb, this, agnst, into);
}
FLAG++;
}
}

View File

@ -510,8 +510,11 @@ Vector Vector::ScaledBy(double v) {
Vector Vector::WithMagnitude(double v) {
double m = Magnitude();
if(m == 0) {
dbp("Vector::WithMagnitude of zero vector!");
return From(v, 0, 0);
// We can do a zero vector with zero magnitude, but not any other cases.
if(fabs(v) > 1e-100) {
dbp("Vector::WithMagnitude of zero vector!");
}
return From(0, 0, 0);
} else {
return ScaledBy(v/m);
}