Commit 2299b24d authored by Davis King's avatar Davis King

Fixed some confusing bits of the vector spec and also

added a unary - operator.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402815
parent d524f264
......@@ -522,6 +522,14 @@ namespace dlib
// ---------------------------------------
vector operator - (
) const
{
return vector(-x(), -y(), -z());
}
// ---------------------------------------
vector operator - (
const vector& rhs
) const
......@@ -869,6 +877,14 @@ namespace dlib
// ---------------------------------------
vector operator - (
) const
{
return vector(-x(), -y());
}
// ---------------------------------------
vector operator - (
const vector& rhs
) const
......
......@@ -145,7 +145,7 @@ namespace dlib
!*/
T length(
double length(
) const;
/*!
ensures
......@@ -216,7 +216,7 @@ namespace dlib
- returns the result of the cross product between *this and rhs
!*/
vector normalize (
vector<double,NR> normalize (
) const;
/*!
ensures
......@@ -239,6 +239,13 @@ namespace dlib
- returns the result of subtracting rhs from *this
!*/
vector operator- (
) const;
/*!
ensures
- returns -1*(*this)
!*/
vector operator/ (
const T rhs
) const;
......
......@@ -38,6 +38,10 @@ namespace
DLIB_CASSERT(p2.x() == 2,"");
DLIB_CASSERT(p2.y() == 3,"");
DLIB_CASSERT((-p2).x() == -2,"");
DLIB_CASSERT((-p2).y() == -3,"");
p2 += p2;
DLIB_CASSERT(p2.x() == 4,"");
DLIB_CASSERT(p2.y() == 6,"");
......@@ -238,6 +242,13 @@ namespace
}
{
dlib::vector<double> v(3,4,5);
DLIB_CASSERT((-v).x() == -3.0,"");
DLIB_CASSERT((-v).y() == -4.0,"");
DLIB_CASSERT((-v).z() == -5.0,"");
}
}
......
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