line.h revision 40742313779ee5e43be93a9191f1c86412cf183b
/**
* \file
* \brief Infinite straight line
*//*
* Authors:
* Marco Cecchetti <mrcekets at gmail.com>
* Krzysztof KosiĆski <tweenk.pl@gmail.com>
* Copyright 2008-2011 Authors
*
* modify it either under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* (the "LGPL") or, at your option, under the terms of the Mozilla
* Public License Version 1.1 (the "MPL"). If you do not alter this
* notice, a recipient may use your version of this file under either
* the MPL or the LGPL.
*
* You should have received a copy of the LGPL along with this library
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* You should have received a copy of the MPL along with this library
* in the file COPYING-MPL-1.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
* the specific language governing rights and limitations.
*/
#ifndef LIB2GEOM_SEEN_LINE_H
#define LIB2GEOM_SEEN_LINE_H
#include <cmath>
#include <boost/optional.hpp>
{
/// @name Creating lines.
/// @{
/** @brief Create a default horizontal line. */
Line()
{}
/** @brief Create a line with the specified inclination.
* @param _origin One of the points on the line
* @param angle Angle of the line in mathematical convention */
{
}
/** @brief Create a line going through two points.
* @param A First point
* @param B Second point */
setPoints(A, B);
}
/** @brief Create a line based on the coefficients of its equation.
@see Line::setCoefficients() */
Line(double a, double b, double c) {
setCoefficients(a, b, c);
}
/** @brief Create a line by extending a line segment. */
}
/** @brief Create a line by extending a ray. */
{}
// huh?
return l;
}
/** @brief Create a line from origin and unit vector.
* Note that each line direction has two possible unit vectors.
* @param o Point through which the line will pass
* @param v Unit vector of the line's direction */
Line l;
l.m_origin = o;
l.m_versor = v;
return l;
}
}
/// @}
/// @name Retrieve and set the line's parameters.
/// @{
/** @brief Get the line's origin point. */
/** @brief Get the line's direction unit vector. */
// return the angle described by rotating the X-axis in cw direction
// until it overlaps the line
// the returned value is in the interval [0, PI[
if (a < 0) a += M_PI;
if (a == M_PI) a = 0;
return a;
}
}
}
}
/** @brief Set a line based on two points it should pass through. */
m_origin = A;
if ( are_near(A, B) )
else
m_versor = B - A;
}
void setCoefficients (double a, double b, double c);
/** @brief Check if the line has any points.
* A degenerate line can be created if the line is created from a line equation
* that has no solutions.
* @return True if the line has no points */
bool isDegenerate() const {
}
/// @}
/// @name Evaluate the line as a function.
///@{
}
if (d < 0 || d > 1)
THROW_RANGEERROR("Line::valueAt, dimension argument out of range");
}
/** @brief Get a time value corresponding to a projection of a point on the line.
* @param p Arbitrary point.
* @return Time value corresponding to a point closest to @c p. */
if ( isDegenerate() ) return 0;
}
/** @brief Find a point on the line closest to the query point.
* This is an alias for timeAtProjection(). */
return timeAtProjection(_point);
}
/// @}
/// @name Create other objects based on this line.
/// @{
/** @brief Create a line containing the same points, but with negated time values.
* @return Line \f$g\f$ such that \f$g(t) = f(-t)\f$ */
{
return result;
}
/** @brief Same as segment(), but allocate the line segment dynamically. */
// TODO remove this?
return seg;
}
/** @brief Create a segment of this line.
* @param f Time value for the initial point of the segment
* @param t Time value for the final point of the segment
* @return Created line segment */
}
/** @brief Create a ray starting at the specified time value.
* The created ray will go in the direction of the line's versor (in the direction
* of increasing time values).
* @param t Time value where the ray should start
* @return Ray starting at t and going in the direction of the versor */
return result;
}
/** @brief Create a derivative of the line.
* The new line will always be degenerate. Its origin will be equal to this
* line's versor. */
Line derivative() const {
return result;
}
/** @brief Create a line transformed by an affine transformation. */
}
/** @brief Get a vector normal to the line.
* If Y grows upwards, then this is the left normal. If Y grows downwards,
* then this is the right normal. */
}
// what does this do?
return n;
}
/// @}
}; // end class Line
inline
{
if ( _line.isDegenerate() )
{
}
else
{
}
}
inline
{
}
inline
{
}
inline
{
}
inline
{
}
inline
{
}
// evaluate the angle between l1 and l2 rotating l1 in cw direction
// until it overlaps l2
// the returned value is an angle in the interval [0, PI[
inline
{
return angle;
}
inline
{
}
inline
{
}
// build a line passing by _point and orthogonal to _line
inline
{
Line l;
return l;
}
// build a line passing by _point and parallel to _line
inline
{
return l;
}
// build a line passing by the middle point of _segment and orthogonal to it.
inline
{
}
// build the bisector line of the angle between ray(O,A) and ray(O,B)
inline
{
Point M = middle_point(A,B);
return Line(O,M);
}
// prj(P) = rot(v, Point( rot(-v, P-O)[X], 0 )) + O
inline
{
}
inline
{
}
{
unsigned int i );
unsigned int i );
}
inline
{
}
inline
{
}
inline
{
}
inline
{
}
inline
{
}
inline
{
}
} // end namespace Geom
#endif // LIB2GEOM_SEEN_LINE_H
/*
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:fileencoding=utf-8:textwidth=99 :