diff options
| author | Diederik van Lierop <mailat-signdiedenrezidotnl> | 2010-07-17 20:13:52 +0000 |
|---|---|---|
| committer | Diederik van Lierop <mailat-signdiedenrezidotnl> | 2010-07-17 20:13:52 +0000 |
| commit | 846961debf7ef8d98f081509c4aa4ca5b880e25d (patch) | |
| tree | fc13677062417af2cc07802702f5bd4c66d8d3d0 /src/line-snapper.cpp | |
| parent | Fix build failure when DBus is not enabled (diff) | |
| download | inkscape-846961debf7ef8d98f081509c4aa4ca5b880e25d.tar.gz inkscape-846961debf7ef8d98f081509c4aa4ca5b880e25d.zip | |
Simplify code related to snapping while rotating
(bzr r9619)
Diffstat (limited to 'src/line-snapper.cpp')
| -rw-r--r-- | src/line-snapper.cpp | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp index 5ceece66b..19e6c0fe6 100644 --- a/src/line-snapper.cpp +++ b/src/line-snapper.cpp @@ -83,16 +83,11 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc, // First, project the origin of the circle onto the line Geom::Point const origin = c.getPoint(); Geom::Point const p_proj = Geom::projection(origin, gridguide_line); - Geom::Point v_orig = c.getDirection(); // vector from the origin to the original (untransformed) point - Geom::Point v_proj = p_proj - origin; - Geom::Coord dist = Geom::L2(v_proj); // distance from circle origin to constraint line + Geom::Coord dist = Geom::L2(p_proj - origin); // distance from circle origin to constraint line Geom::Coord radius = c.getRadius(); - Geom::Coord radians = NR_HUGE; if (dist == radius) { // Only one point of intersection; - // Calculate the rotation in radians... - radians = atan2(Geom::dot(Geom::rot90(v_orig), v_proj), Geom::dot(v_orig, v_proj)); - _addSnappedPoint(sc, p_proj, Geom::L2(p.getPoint() - p_proj), p.getSourceType(), p.getSourceNum(), true, radians); + _addSnappedPoint(sc, p_proj, Geom::L2(p.getPoint() - p_proj), p.getSourceType(), p.getSourceNum(), true); } else if (dist < radius) { // Two points of intersection, symmetrical with respect to the projected point // Calculate half the length of the linesegment between the two points of intersection @@ -100,12 +95,8 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc, Geom::Coord d = Geom::L2(gridguide_line.versor()); // length of versor, needed to normalize the versor if (d > 0) { Geom::Point v = l*gridguide_line.versor()/d; - v_proj = p_proj + v - origin; - radians = atan2(Geom::dot(Geom::rot90(v_orig), v_proj), Geom::dot(v_orig, v_proj)); - _addSnappedPoint(sc, p_proj + v, Geom::L2(p.getPoint() - (p_proj + v)), p.getSourceType(), p.getSourceNum(), true, radians); - v_proj = p_proj - v - origin; - radians = atan2(Geom::dot(Geom::rot90(v_orig), v_proj), Geom::dot(v_orig, v_proj)); - _addSnappedPoint(sc, p_proj - v, Geom::L2(p.getPoint() - (p_proj - v)), p.getSourceType(), p.getSourceNum(), true, radians); + _addSnappedPoint(sc, p_proj + v, Geom::L2(p.getPoint() - (p_proj + v)), p.getSourceType(), p.getSourceNum(), true); + _addSnappedPoint(sc, p_proj - v, Geom::L2(p.getPoint() - (p_proj - v)), p.getSourceType(), p.getSourceNum(), true); } } } else { @@ -130,7 +121,7 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc, // This snappoint is therefore fully constrained, so there's no need // to look for additional intersections; just return the snapped point // and forget about the line - _addSnappedPoint(sc, t, dist, p.getSourceType(), p.getSourceNum(), true, 1); + _addSnappedPoint(sc, t, dist, p.getSourceType(), p.getSourceNum(), true); } } } |
