00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef WFMATH_SEGMENT_FUNCS_H
00027 #define WFMATH_SEGMENT_FUNCS_H
00028
00029 #include <wfmath/const.h>
00030 #include <wfmath/point.h>
00031 #include <wfmath/segment.h>
00032
00033 namespace WFMath {
00034
00035 template<const int dim>
00036 bool Segment<dim>::isEqualTo(const Segment<dim>& s, double epsilon) const
00037 {
00038 return Equal(m_p1, s.m_p1, epsilon)
00039 && Equal(m_p2, s.m_p2, epsilon);
00040 }
00041
00042 template<const int dim>
00043 bool Segment<dim>::operator< (const Segment& s) const
00044 {
00045 if(!Equal(m_p1, s.m_p1))
00046 return m_p1 < s.m_p1;
00047 else
00048 return m_p2 < s.m_p2;
00049 }
00050
00051 template<const int dim>
00052 Segment<dim>& Segment<dim>::moveCornerTo(const Point<dim>& p, int corner)
00053 {
00054 assert(corner == 0 || corner == 1);
00055
00056 Vector<dim> diff = m_p2 - m_p1;
00057
00058 if(!corner) {
00059 m_p1 = p;
00060 m_p2 = p + diff;
00061 }
00062 else {
00063 m_p2 = p;
00064 m_p1 = p - diff;
00065 }
00066
00067 return *this;
00068 }
00069
00070 template<const int dim>
00071 Segment<dim>& Segment<dim>::rotateCorner(const RotMatrix<dim>& m, int corner)
00072 {
00073 assert(corner == 0 || corner == 1);
00074
00075 if(corner)
00076 m_p1.rotate(m, m_p2);
00077 else
00078 m_p2.rotate(m, m_p1);
00079
00080 return *this;
00081 }
00082
00083 }
00084
00085 #endif // WFMATH_SEGMENT_FUNCS_H