From dfd48bd9b4e9c017a5045b202deb7d9dd514e5b4 Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Fri, 17 Aug 2007 18:42:23 +0000 Subject: Enable center-dragging of boxes ('in perspective') within the XY-plane (bzr r3497) --- src/perspective-line.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/perspective-line.cpp') diff --git a/src/perspective-line.cpp b/src/perspective-line.cpp index 9ee2d3578..90857e6d5 100644 --- a/src/perspective-line.cpp +++ b/src/perspective-line.cpp @@ -51,6 +51,23 @@ NR::Point PerspectiveLine::meet(Line const &line) return *intersect(line); // works since intersect() does not return NR::Nothing() } +NR::Point PerspectiveLine::pt_with_given_cross_ratio (NR::Point const &C, NR::Point const &D, double gamma) +{ + if (persp->get_vanishing_point (vp_dir)->is_finite()) { + NR::Point V (*persp->get_vanishing_point (vp_dir)); + return fourth_pt_with_given_cross_ratio (V, C, D, gamma); + } else { + if (fabs (gamma - 1) < epsilon) { + g_warning ("Cannot compute point with given cross ratio.\n"); + return NR::Point (0.0, 0.0); + } + Line line (C, D); + double lambda_C = line.lambda (C); + double lambda_D = line.lambda (D); + return line.point_from_lambda ((lambda_D - gamma * lambda_C) / (1 - gamma)); + } +} + NR::Maybe PerspectiveLine::intersection_with_viewbox (SPDesktop *desktop) { NR::Rect vb = desktop->get_display_area(); -- cgit v1.2.3