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:
parent
6109a2086d
commit
08135223ce
@ -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;
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user