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
inline 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
inline Segment<dim>& Segment<dim>::moveCornerTo(
const Point<dim>& p,
int corner)
00044 {
00045 assert(corner == 0 || corner == 1);
00046
00047 Vector<dim> diff = m_p2 - m_p1;
00048
00049
if(!corner) {
00050 m_p1 = p;
00051 m_p2 = p + diff;
00052 }
00053
else {
00054 m_p2 = p;
00055 m_p1 = p - diff;
00056 }
00057
00058
return *
this;
00059 }
00060
00061
template<const
int dim>
00062
inline Segment<dim>& Segment<dim>::rotateCorner(
const RotMatrix<dim>& m,
int corner)
00063 {
00064 assert(corner == 0 || corner == 1);
00065
00066
if(corner)
00067 m_p1.rotate(m, m_p2);
00068
else
00069 m_p2.rotate(m, m_p1);
00070
00071
return *
this;
00072 }
00073
00074
template<>
00075
inline Segment<3>& Segment<3>::rotateCorner(
const Quaternion& q,
int corner)
00076 {
00077 assert(corner == 0 || corner == 1);
00078
00079
if(corner)
00080 m_p1.rotate(q, m_p2);
00081
else
00082 m_p2.rotate(q, m_p1);
00083
00084
return *
this;
00085 }
00086
00087 }
00088
00089
#endif // WFMATH_SEGMENT_FUNCS_H