line-geometry.cpp revision 492de225e9b11f35d98b6b75efa58e115ee688fa
#define __LINE_GEOMETRY_C__
/*
* Routines for dealing with lines (intersections, etc.)
*
* Authors:
* Maximilian Albert <Anhalter42@gmx.de>
*
* Copyright (C) 2007 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "line-geometry.h"
#include "inkscape.h"
#include "desktop-style.h"
#include "desktop-handles.h"
#include "display/sp-canvas.h"
#include "display/sodipodi-ctrl.h"
namespace Box3D {
/**
* Draw a line beginning at 'start'. If is_endpoint is true, use 'vec' as the endpoint
* of the segment. Otherwise interpret it as the direction of the line.
* FIXME: Think of a better way to distinguish between the two constructors of lines.
*/
if (is_endpoint)
else
}
}
return *this;
}
return no_point;
}
{
}
{
/* return the intersection of this line with a perpendicular line passing through pt */
return *result;
}
{
// FIXME: It may speed things up (but how much?) if we assume that
// pt lies on the line and thus skip the following test
g_warning ("Point does not lie on line.\n");
return 0;
}
return lambda;
}
{
}
/* The coordinates of w with respect to the basis {v1, v2} */
std::pair<double, double> coordinates (NR::Point const &v1, NR::Point const &v2, NR::Point const &w)
{
// vectors are not linearly independent; we indicate this in the return value(s)
}
}
/* whether w lies inside the sector spanned by v1 and v2 */
{
// catch the case that the vectors are not linearly independent
// FIXME: Can we assume that it's safe to return true if the vectors point in different directions?
}
}
bool lies_in_quadrangle (NR::Point const &A, NR::Point const &B, NR::Point const &C, NR::Point const &D, NR::Point const &pt)
{
}
{
}
/*
* Returns the two corners of the quadrangle A, B, C, D spanning the edge that is hit by a semiline
* starting at pt and going into direction dir.
* If none of the sides is hit, it returns a pair containing two identical points.
*/
side_of_intersection (NR::Point const &A, NR::Point const &B, NR::Point const &C, NR::Point const &D,
{
double angle = -1;
double tmp_angle;
}
}
}
}
}
}
}
if (angle == -1) {
// no intersection found; return a pair containing two identical points
} else {
return result;
}
}
{
// FIXME: What should we return if the cross ratio can't be computed?
return 0;
//return NR_HUGE;
}
return (((lambda_C - lambda_A) / (lambda_D - lambda_A)) * ((lambda_D - lambda_B) / (lambda_C - lambda_B)));
}
double cross_ratio (VanishingPoint const &V, NR::Point const &B, NR::Point const &C, NR::Point const &D)
{
if (V.is_finite()) {
return cross_ratio (V.get_pos(), B, C, D);
} else {
// FIXME: What should we return if the cross ratio can't be computed?
return 0;
//return NR_HUGE;
}
}
}
NR::Point fourth_pt_with_given_cross_ratio (NR::Point const &A, NR::Point const &C, NR::Point const &D, double gamma)
{
// FIXME: How to handle the case when the point can't be computed?
// g_warning ("Cannot compute point with given cross ratio.\n");
}
}
{
"size", size,
"filled", 1,
"fill_color", rgba,
"stroked", 1,
"stroke_color", 0x000000ff,
NULL);
}
{
}
} // 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 :