Commit af3a2188 authored by Eddie Kohler's avatar Eddie Kohler

add shear and transform methods

parent 1422a336
......@@ -22,13 +22,16 @@ class Transform { public:
void rotate(double);
void translate(double, double);
void translate(const Point &p) { translate(p.x, p.y); }
void shear(double);
inline void transform(const Transform &);
inline Transform scaled(double, double) const;
Transform scaled(const Point &p) const { return scaled(p.x, p.y); }
Transform scaled(double d) const { return scaled(d, d); }
Transform rotated(double) const;
Transform translated(double, double) const;
Transform translated(const Point &p) const;
inline Transform rotated(double) const;
inline Transform translated(double, double) const;
inline Transform translated(const Point &p) const;
inline Transform sheared(double) const;
Transform transformed(const Transform &) const;
// Transform operator+(Transform, const Point &);
......@@ -84,6 +87,14 @@ Transform::translated(const Point &p) const
return translated(p.x, p.y);
}
inline Transform
Transform::sheared(double s) const
{
Transform t(*this);
t.shear(s);
return t;
}
inline Transform &
operator+=(Transform &t, const Point &p)
......@@ -124,6 +135,12 @@ operator*=(Transform &t, const Transform &tt)
return t;
}
inline void
Transform::transform(const Transform &t)
{
*this *= t;
}
inline Point &
operator*=(Point &p, const Transform &t)
......
......@@ -98,6 +98,12 @@ Transform::translate(double x, double y)
_null = false;
}
void
Transform::shear(double s)
{
*this *= Transform(1, 0, s, 1, 0, 0);
}
Transform
Transform::transformed(const Transform &t) const
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment