From 0a2477feea6e1df586b926b8482afbf79e2355e1 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 7 Feb 2016 23:32:51 -0800 Subject: Sync 2Geom to commit 5ee51c1c4f2066faa3e2c82021fc92671ad44ba4 (bzr r14639) --- src/2geom/line.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/2geom/line.cpp') diff --git a/src/2geom/line.cpp b/src/2geom/line.cpp index bada8ef38..ee2edeba7 100644 --- a/src/2geom/line.cpp +++ b/src/2geom/line.cpp @@ -235,6 +235,20 @@ Coord Line::timeAt(Point const &p) const } } +/** @brief Create a transformation that maps one line to another. + * This will return a transformation \f$A\f$ such that + * \f$L_1(t) \cdot A = L_2(t)\f$, where \f$L_1\f$ is this line + * and \f$L_2\f$ is the line passed as the parameter. The returned + * transformation will preserve angles. */ +Affine Line::transformTo(Line const &other) const +{ + Affine result = Translate(-_initial); + result *= Rotate(angle_between(versor(), other.versor())); + result *= Scale(other.versor().length() / versor().length()); + result *= Translate(other._initial); + return result; +} + std::vector Line::intersect(Line const &other) const { std::vector result; -- cgit v1.2.3