Commit aec7c847 authored by Davis King's avatar Davis King

Cleaned up the vector and point classes. Now there is only one class, the vector,

class and it is capable of representing everything the old vector and point
class could.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402727
parent 3fc0a290
...@@ -70,17 +70,6 @@ namespace dlib ...@@ -70,17 +70,6 @@ namespace dlib
{ {
} }
template <typename T>
rectangle (
const vector<T>& v
) :
l(static_cast<long>(v.x()+0.5)),
t(static_cast<long>(v.y()+0.5)),
r(static_cast<long>(v.x()+0.5)),
b(static_cast<long>(v.y()+0.5))
{
}
rectangle ( rectangle (
const point& p1, const point& p1,
const point& p2 const point& p2
...@@ -89,15 +78,6 @@ namespace dlib ...@@ -89,15 +78,6 @@ namespace dlib
*this = rectangle(p1) + rectangle(p2); *this = rectangle(p1) + rectangle(p2);
} }
template <typename T>
rectangle (
const vector<T>& v1,
const vector<T>& v2
)
{
*this = rectangle(v1) + rectangle(v2);
}
rectangle ( rectangle (
) : ) :
l(0), l(0),
...@@ -228,6 +208,14 @@ namespace dlib ...@@ -228,6 +208,14 @@ namespace dlib
return (rect + *this == *this); return (rect + *this == *this);
} }
rectangle& operator+= (
const point& p
)
{
*this = *this + rectangle(p);
return *this;
}
rectangle& operator+= ( rectangle& operator+= (
const rectangle& rect const rectangle& rect
) )
......
...@@ -90,18 +90,6 @@ namespace dlib ...@@ -90,18 +90,6 @@ namespace dlib
- #bottom() == p.y() - #bottom() == p.y()
!*/ !*/
template <typename T>
rectangle (
const vector<T>& v
);
/*!
ensures
- #left() == static_cast<long>(floor(v.x()+0.5))
- #top() == static_cast<long>(floor(v.y()+0.5))
- #right() == static_cast<long>(floor(v.x()+0.5))
- #bottom() == static_cast<long>(floor(v.y()+0.5))
!*/
rectangle ( rectangle (
const point& p1, const point& p1,
const point& p2 const point& p2
...@@ -111,16 +99,6 @@ namespace dlib ...@@ -111,16 +99,6 @@ namespace dlib
- #*this == rectangle(p1) + rectangle(p2) - #*this == rectangle(p1) + rectangle(p2)
!*/ !*/
template <typename T>
rectangle (
const vector<T>& v1,
const vector<T>& v2
);
/*!
ensures
- #*this == rectangle(v1) + rectangle(v2)
!*/
long left ( long left (
) const; ) const;
/*! /*!
......
This diff is collapsed.
This diff is collapsed.
...@@ -129,6 +129,65 @@ namespace ...@@ -129,6 +129,65 @@ namespace
DLIB_CASSERT(v1.y() == 6,""); DLIB_CASSERT(v1.y() == 6,"");
DLIB_CASSERT(v1.z() == 7,""); DLIB_CASSERT(v1.z() == 7,"");
{
dlib::vector<double,2> vd2;
dlib::vector<double,3> vd3;
dlib::vector<long,2> vl2;
dlib::vector<long,3> vl3;
vd2.x() = 2.3;
vd2.y() = 4.7;
vd3.z() = 9;
vd3 = vd2;
vl2 = vd3;
vl3 = vd3;
DLIB_CASSERT(vd2.z() == 0,"");
DLIB_CASSERT(vd3.z() == 0,"");
DLIB_CASSERT(vl2.z() == 0,"");
DLIB_CASSERT(vl3.z() == 0,"");
DLIB_CASSERT(vl2.x() == 2,"");
DLIB_CASSERT(vl3.x() == 2,"");
DLIB_CASSERT(vl2.y() == 5,"");
DLIB_CASSERT(vl3.y() == 5,"");
DLIB_CASSERT(abs(vd2.cross(vd3).dot(vd2)) < 1e-7,"");
DLIB_CASSERT(abs(vd3.cross(vd2).dot(vd2)) < 1e-7,"");
DLIB_CASSERT(abs(vd2.cross(vd3).dot(vd3)) < 1e-7,"");
DLIB_CASSERT(abs(vd3.cross(vd2).dot(vd3)) < 1e-7,"");
DLIB_CASSERT(abs(vl2.cross(vl3).dot(vl2)) == 0,"");
DLIB_CASSERT(abs(vl3.cross(vl2).dot(vl2)) == 0,"");
DLIB_CASSERT(abs(vl2.cross(vl3).dot(vl3)) == 0,"");
DLIB_CASSERT(abs(vl3.cross(vl2).dot(vl3)) == 0,"");
DLIB_CASSERT((vd2-vd3).length() < 1e-7,"");
DLIB_CASSERT(vl2 == vl3,"");
vl2.x() = 0;
vl2.y() = 0;
vl3 = vl2;
vl2.x() = 4;
vl3.y() = 3;
DLIB_CASSERT(vl2.cross(vl3).length() == 12,"");
DLIB_CASSERT(vl3.cross(vl2).length() == 12,"");
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment