diff options
| author | Maximilian Albert <maximilian.albert@gmail.com> | 2007-06-21 13:01:57 +0000 |
|---|---|---|
| committer | cilix42 <cilix42@users.sourceforge.net> | 2007-06-21 13:01:57 +0000 |
| commit | cf233ff5bbc68bd598ef4b81c7b4063548f2eff9 (patch) | |
| tree | 56d48726d21ad368509a945bf7df91966115cc9c /src/perspective-line.cpp | |
| parent | Fix function plotter for the most common case where there are no transforms a... (diff) | |
| download | inkscape-cf233ff5bbc68bd598ef4b81c7b4063548f2eff9.tar.gz inkscape-cf233ff5bbc68bd598ef4b81c7b4063548f2eff9.zip | |
First (very limited) version of the 3D box tool; allows for drawing of new boxes in a fixed perspective without any live interaction.
(bzr r3084)
Diffstat (limited to 'src/perspective-line.cpp')
| -rw-r--r-- | src/perspective-line.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/perspective-line.cpp b/src/perspective-line.cpp new file mode 100644 index 000000000..b2e4d2340 --- /dev/null +++ b/src/perspective-line.cpp @@ -0,0 +1,63 @@ +#define __PERSPECTIVE_LINE_C__ + +/* + * Perspective line for 3D perspectives + * + * Authors: + * Maximilian Albert <Anhalter42@gmx.de> + * + * Copyright (C) 2007 authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "perspective-line.h" + +namespace Box3D { + +PerspectiveLine::PerspectiveLine (NR::Point const &pt, PerspDir const axis, Perspective3D *perspective) : + Line (pt, *(perspective->get_vanishing_point(axis)), true) +{ + g_assert (perspective != NULL); + + if (perspective->get_vanishing_point(axis)->state == VP_INFINITE) { + this->set_direction(perspective->get_vanishing_point(axis)->v_dir); + } + this->vp_dir = axis; + this->persp = perspective; +} + +// This function makes sure not to return NR::Nothing() +// FIXME: How to gracefully handle parallel lines? +NR::Maybe<NR::Point> PerspectiveLine::intersect (Line const &line) +{ + NR::Maybe<NR::Point> pt = this->Line::intersect(line); + if (!pt) { + Box3D::VanishingPoint vp = *(persp->get_vanishing_point(vp_dir)); + if (vp.state == VP_INFINITE) { + pt = vp; + } else { + pt = NR::Point (0.0, 0.0); // FIXME: Better solution needed + } + } + return pt; +} + +// FIXME: Do we really need two intersection methods? +NR::Point PerspectiveLine::meet(Line const &line) +{ + return *intersect(line); // works since intersect() does not return NR::Nothing() +} + +} // namespace Box3D + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : |
