Base: add Transform/Transformed to Line3<> and Polygon3<>
This commit is contained in:
@@ -109,6 +109,51 @@ Vector3<float_type> Line3<float_type>::GetDirection() const
|
||||
return p2 - p1;
|
||||
}
|
||||
|
||||
template <typename float_type>
|
||||
void Line3<float_type>::Transform(const Base::Matrix4D& mat)
|
||||
{
|
||||
mat.multVec(p1, p1);
|
||||
mat.multVec(p2, p2);
|
||||
}
|
||||
|
||||
template <typename float_type>
|
||||
void Line3<float_type>::Transform(const Base::Placement& plm)
|
||||
{
|
||||
plm.multVec(p1, p1);
|
||||
plm.multVec(p2, p2);
|
||||
}
|
||||
|
||||
template <typename float_type>
|
||||
void Line3<float_type>::Transform(const Base::Rotation& rot)
|
||||
{
|
||||
rot.multVec(p1, p1);
|
||||
rot.multVec(p2, p2);
|
||||
}
|
||||
|
||||
template <typename float_type>
|
||||
Line3<float_type> Line3<float_type>::Transformed(const Base::Matrix4D& mat) const
|
||||
{
|
||||
Line3<float_type> line(*this);
|
||||
line.Transform(mat);
|
||||
return line;
|
||||
}
|
||||
|
||||
template <typename float_type>
|
||||
Line3<float_type> Line3<float_type>::Transformed(const Base::Placement& plm) const
|
||||
{
|
||||
Line3<float_type> line(*this);
|
||||
line.Transform(plm);
|
||||
return line;
|
||||
}
|
||||
|
||||
template <typename float_type>
|
||||
Line3<float_type> Line3<float_type>::Transformed(const Base::Rotation& rot) const
|
||||
{
|
||||
Line3<float_type> line(*this);
|
||||
line.Transform(rot);
|
||||
return line;
|
||||
}
|
||||
|
||||
template <typename float_type>
|
||||
bool Line3<float_type>::Contains(const Vector3<float_type>& pt) const
|
||||
{
|
||||
@@ -201,6 +246,51 @@ BoundBox3<float_type> Polygon3<float_type>::CalcBoundBox() const
|
||||
return box;
|
||||
}
|
||||
|
||||
template <typename float_type>
|
||||
void Polygon3<float_type>::Transform(const Base::Matrix4D& mat)
|
||||
{
|
||||
for (auto& it : points)
|
||||
mat.multVec(it, it);
|
||||
}
|
||||
|
||||
template <typename float_type>
|
||||
void Polygon3<float_type>::Transform(const Base::Placement& plm)
|
||||
{
|
||||
for (auto& it : points)
|
||||
plm.multVec(it, it);
|
||||
}
|
||||
|
||||
template <typename float_type>
|
||||
void Polygon3<float_type>::Transform(const Base::Rotation& rot)
|
||||
{
|
||||
for (auto& it : points)
|
||||
rot.multVec(it, it);
|
||||
}
|
||||
|
||||
template <typename float_type>
|
||||
Polygon3<float_type> Polygon3<float_type>::Transformed(const Base::Matrix4D& mat) const
|
||||
{
|
||||
Polygon3<float_type> poly(*this);
|
||||
poly.Transform(mat);
|
||||
return poly;
|
||||
}
|
||||
|
||||
template <typename float_type>
|
||||
Polygon3<float_type> Polygon3<float_type>::Transformed(const Base::Placement& plm) const
|
||||
{
|
||||
Polygon3<float_type> poly(*this);
|
||||
poly.Transform(plm);
|
||||
return poly;
|
||||
}
|
||||
|
||||
template <typename float_type>
|
||||
Polygon3<float_type> Polygon3<float_type>::Transformed(const Base::Rotation& rot) const
|
||||
{
|
||||
Polygon3<float_type> poly(*this);
|
||||
poly.Transform(rot);
|
||||
return poly;
|
||||
}
|
||||
|
||||
// explicit template instantiation
|
||||
namespace Base {
|
||||
template class BaseExport Line3<float>;
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include <Base/BoundBox.h>
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Base/Placement.h>
|
||||
#ifndef FC_GLOBAL_H
|
||||
#include <FCGlobal.h>
|
||||
#endif
|
||||
@@ -58,14 +58,14 @@ public:
|
||||
|
||||
Line3() = default;
|
||||
~Line3() = default;
|
||||
Line3(const Line3<float_type>& line);
|
||||
Line3(Line3<float_type>&& line);
|
||||
Line3(const Line3& line);
|
||||
Line3(Line3&& line);
|
||||
Line3(const Vector3<float_type>& p1, const Vector3<float_type>& p2);
|
||||
|
||||
// operators
|
||||
Line3& operator= (const Line3<float_type>& line);
|
||||
Line3& operator= (Line3<float_type>&& line);
|
||||
bool operator== (const Line3<float_type>& line) const;
|
||||
Line3& operator= (const Line3& line);
|
||||
Line3& operator= (Line3&& line);
|
||||
bool operator== (const Line3& line) const;
|
||||
|
||||
// methods
|
||||
double Length () const;
|
||||
@@ -73,6 +73,12 @@ public:
|
||||
BoundBox3<float_type> CalcBoundBox() const;
|
||||
Vector3<float_type> GetBase() const;
|
||||
Vector3<float_type> GetDirection() const;
|
||||
void Transform(const Base::Matrix4D&);
|
||||
void Transform(const Base::Placement&);
|
||||
void Transform(const Base::Rotation&);
|
||||
Line3 Transformed(const Base::Matrix4D&) const;
|
||||
Line3 Transformed(const Base::Placement&) const;
|
||||
Line3 Transformed(const Base::Rotation&) const;
|
||||
|
||||
/*!
|
||||
* \brief Contains
|
||||
@@ -119,6 +125,12 @@ public:
|
||||
|
||||
// misc
|
||||
BoundBox3<float_type> CalcBoundBox() const;
|
||||
void Transform(const Base::Matrix4D&);
|
||||
void Transform(const Base::Placement&);
|
||||
void Transform(const Base::Rotation&);
|
||||
Polygon3 Transformed(const Base::Matrix4D&) const;
|
||||
Polygon3 Transformed(const Base::Placement&) const;
|
||||
Polygon3 Transformed(const Base::Rotation&) const;
|
||||
|
||||
private:
|
||||
std::vector<Vector3<float_type>> points;
|
||||
|
||||
Reference in New Issue
Block a user