Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions include/cartesian_geom/point.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,36 @@ class point
return coeffs.sum();
}

template<typename T>
void operator+= (const T& other)
{
if (other.rows() == 1 && other.cols() == d && d > 1) {
this->coeffs += other.transpose();
} else {
this->coeffs += other;
}
}

void operator+= (const point& p)
{
coeffs += p.getCoefficients();
}

void operator+= (const Coeff& coeffs)

template<typename T>
void operator-= (const T& other)
{
this->coeffs += coeffs;
if (other.rows() == 1 && other.cols() == d && d > 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this check needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had initially put that in, keeping in mind this bit of code from hpolytope.h

 void compute_reflection(Point& v, Point const&, int const& facet) const
    {
        v += -2 * v.dot(A.row(facet)) * A.row(facet);
    }

to my knowledge, a row vector was being added to a column vector, which is why the tranpose was needed. But I tried it out, removing the check and it seems to work? perhaps it has something to do with how Eigen handles it, but yes, the check seems to not be necessary.

this->coeffs -= other.transpose();
} else {
this->coeffs -= other;
}
}

void operator-= (const point& p)
{
coeffs -= p.getCoefficients();
}

void operator-= (const Coeff& coeffs)
{
this->coeffs -= coeffs;
}

void operator= (const Coeff& coeffs)
{
Expand Down Expand Up @@ -205,8 +216,7 @@ class point
}

FT squared_length() const {
FT lsq = length();
return lsq * lsq;
return coeffs.squaredNorm();
}

FT length() const {
Expand Down
Loading