summaryrefslogtreecommitdiffstats
path: root/src/perspective-line.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/perspective-line.cpp')
-rw-r--r--src/perspective-line.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/perspective-line.cpp b/src/perspective-line.cpp
index e5596cc1b..9ee2d3578 100644
--- a/src/perspective-line.cpp
+++ b/src/perspective-line.cpp
@@ -12,6 +12,7 @@
*/
#include "perspective-line.h"
+#include "desktop.h"
namespace Box3D {
@@ -50,6 +51,23 @@ NR::Point PerspectiveLine::meet(Line const &line)
return *intersect(line); // works since intersect() does not return NR::Nothing()
}
+NR::Maybe<NR::Point> PerspectiveLine::intersection_with_viewbox (SPDesktop *desktop)
+{
+ NR::Rect vb = desktop->get_display_area();
+ /* remaining viewbox corners */
+ NR::Point ul (vb.min()[NR::X], vb.max()[NR::Y]);
+ NR::Point lr (vb.max()[NR::X], vb.min()[NR::Y]);
+
+ std::pair <NR::Point, NR::Point> e = side_of_intersection (vb.min(), lr, vb.max(), ul, this->pt, this->v_dir);
+ if (e.first == e.second) {
+ // perspective line lies outside the canvas
+ return NR::Nothing();
+ }
+
+ Line line (e.first, e.second);
+ return this->intersect (line);
+}
+
} // namespace Box3D
/*