Affine transforms: add method to test for dilation

* Add IsDilation() to BAffineTransform and Transformable which check
  whether the transform is a dilation, i.e. consists of only
  translation and/or scaling
This commit is contained in:
Julian Harnath 2015-11-09 17:53:12 +01:00
parent 6109a2086d
commit 08135223ce
4 changed files with 20 additions and 0 deletions

View File

@ -171,6 +171,8 @@ public:
= kDefaultEpsilon) const;
bool IsIdentity(double epsilon
= kDefaultEpsilon) const;
bool IsDilation(double epsilon
= kDefaultEpsilon) const;
bool IsEqual(const BAffineTransform& other,
double epsilon
= kDefaultEpsilon) const;

View File

@ -513,6 +513,14 @@ BAffineTransform::IsIdentity(double epsilon) const
}
bool
BAffineTransform::IsDilation(double epsilon) const
{
return IsEqualEpsilon(shy, 0.0, epsilon)
&& IsEqualEpsilon(shx, 0.0, epsilon);
}
bool
BAffineTransform::IsEqual(const BAffineTransform& other, double epsilon) const
{

View File

@ -169,6 +169,15 @@ Transformable::IsIdentity() const
}
bool
Transformable::IsDilation() const
{
double m[6];
store_to(m);
return m[1] == 0.0 && m[2] == 0.0;
}
void
Transformable::Transform(double* x, double* y) const
{

View File

@ -38,6 +38,7 @@ class Transformable : public BArchivable,
void Reset();
bool IsIdentity() const;
bool IsDilation() const;
// bool operator==(const Transformable& other) const;
// bool operator!=(const Transformable& other) const;