From 55646dba8a87d1a45507794a828ba5dbd90806d0 Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Wed, 29 Aug 2007 13:43:29 +0000 Subject: Constrained center-dragging for 3D boxes (with Ctrl) (bzr r3608) --- src/line-geometry.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/line-geometry.cpp') diff --git a/src/line-geometry.cpp b/src/line-geometry.cpp index 5d8eca8a1..7b6ba0449 100644 --- a/src/line-geometry.cpp +++ b/src/line-geometry.cpp @@ -192,9 +192,8 @@ double cross_ratio (NR::Point const &A, NR::Point const &B, NR::Point const &C, double lambda_D = line.lambda (D); if (fabs (lambda_D - lambda_A) < epsilon || fabs (lambda_C - lambda_B) < epsilon) { - // FIXME: What should we return if the cross ratio can't be computed? - return 0; - //return NR_HUGE; + // We return NR_HUGE so that we can catch this case in the calling functions + return NR_HUGE; } return (((lambda_C - lambda_A) / (lambda_D - lambda_A)) * ((lambda_D - lambda_B) / (lambda_C - lambda_B))); } @@ -204,15 +203,18 @@ double cross_ratio (VanishingPoint const &V, NR::Point const &B, NR::Point const if (V.is_finite()) { return cross_ratio (V.get_pos(), B, C, D); } else { + if (B == D) { + // catch this case so that the line BD below is non-degenerate + return 0; + } Line line (B, D); double lambda_B = line.lambda (B); double lambda_C = line.lambda (C); double lambda_D = line.lambda (D); if (fabs (lambda_C - lambda_B) < epsilon) { - // FIXME: What should we return if the cross ratio can't be computed? - return 0; - //return NR_HUGE; + // We return NR_HUGE so that we can catch this case in the calling functions + return NR_HUGE; } return (lambda_D - lambda_B) / (lambda_C - lambda_B); } -- cgit v1.2.3