Skip to content
Snippets Groups Projects
Commit 5a735ce6 authored by Niklaus Johner's avatar Niklaus Johner
Browse files

Made behavior of Vec3List more numpy like

parent 23d1c577
No related branches found
No related tags found
No related merge requests found
......@@ -108,6 +108,8 @@ void export_Vec3()
.def(self + Real())
.def(Real() + self)
.def(self - self)
.def(self == self)
.def(self != self)
.add_property("center", &Vec3List::GetCenter)
.add_property("inertia", &Vec3List::GetInertia)
.add_property("principal_axes", &Vec3List::GetPrincipalAxes)
......
......@@ -228,9 +228,25 @@ public:
base_type::operator=(rhs);
return *this;
}
//! comparable
bool operator==(const Vec3List& rhs) const
{
if (this->size()!=rhs.size()){
throw std::length_error("Vec3List must have the same size");
}
for (unsigned int i=0;i!=this->size();++i) {
if (((*this)[i])!=((rhs)[i])){
return false;
}
}
return true;
}
//! addable op
Vec3List& operator+=(const Vec3List& rhs)
{
if (this->size()!=rhs.size()){
throw std::length_error("Vec3List must have the same size");
}
for (unsigned int i=0;i!=this->size();++i) {
(*this)[i]+=(rhs)[i];
}
......@@ -246,7 +262,10 @@ public:
//! subtractable op
Vec3List& operator-=(const Vec3List& rhs)
{
{
if (this->size()!=rhs.size()){
throw std::length_error("Vec3List must have the same size");
}
for (unsigned int i=0;i!=this->size();++i) {
(*this)[i]-=(rhs)[i];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment