diff options
| author | Maximilian Albert <maximilian.albert@gmail.com> | 2007-08-17 18:42:23 +0000 |
|---|---|---|
| committer | cilix42 <cilix42@users.sourceforge.net> | 2007-08-17 18:42:23 +0000 |
| commit | dfd48bd9b4e9c017a5045b202deb7d9dd514e5b4 (patch) | |
| tree | 22e6dad0880bf0cf365f02fe5a41ccf139281a1f /src/perspective-line.cpp | |
| parent | Fix skel-strokes example. (diff) | |
| download | inkscape-dfd48bd9b4e9c017a5045b202deb7d9dd514e5b4.tar.gz inkscape-dfd48bd9b4e9c017a5045b202deb7d9dd514e5b4.zip | |
Enable center-dragging of boxes ('in perspective') within the XY-plane
(bzr r3497)
Diffstat (limited to '')
| -rw-r--r-- | src/perspective-line.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
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<NR::Point> PerspectiveLine::intersection_with_viewbox (SPDesktop *desktop) { NR::Rect vb = desktop->get_display_area(); |
