line.h revision 19a11b8fc8f08b40b0612d70011a367c4e2b98ee
/**
* \file
* \brief Infinite Straight Line
*
* Copyright 2008 Marco Cecchetti <mrcekets at gmail.com>
*
* 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 _2GEOM_LINE_H_
#define _2GEOM_LINE_H_
#include <cmath>
{
{
Line()
{
}
{
}
{
setBy2Points(A, B);
}
{
}
{
}
}
{
}
{
return m_origin;
}
{
return m_versor;
}
{
}
{
}
// 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;
}
{
}
{
m_origin = A;
m_versor = B - A;
else
}
bool isDegenerate() const
{
}
{
}
{
if (d < 0 || d > 1)
THROW_RANGEERROR("Ray::valueAt, dimension argument out of range");
}
{
if (d < 0 || d > 1)
THROW_RANGEERROR("Ray::roots, dimension argument out of range");
if ( m_versor[d] != 0 )
{
}
// TODO: else ?
return result;
}
// require are_near(_point, *this)
// on the contrary the result value is meaningless
{
Coord t;
if ( m_versor[X] != 0 )
{
}
else if ( m_versor[Y] != 0 )
{
}
else // degenerate case
{
t = 0;
}
return t;
}
{
if ( isDegenerate() ) return 0;
}
{
return timeAtProjection(_point);
}
{
return result;
}
{
return seg;
}
{
}
{
return result;
}
Line derivative() const
{
return result;
}
{
}
}
}; // 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 // _2GEOM_LINE_H_
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(substatement-open . 0))
indent-tabs-mode:nil
c-brace-offset:0
fill-column:99
End:
vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
*/