Logo Search packages:      
Sourcecode: inkscape version File versions

NR::Coord Snapper::intersector_a_vector_snap ( NR::Point &  req,
NR::Point const &  mv,
NR::Point const &  n,
NR::Coord const   d 
) const [protected]

Add some multiple of mv to req to make it line on the line {p : dot(n, p) == d} (within rounding error); unless that isn't possible (e.g. mv and n are orthogonal, or mv or n is zero-length), in which case req remains unchanged, and a big number is returned.

Returns:
a badness measure of snapping to the specified line: if snapping was possible then L2(req - req0) (i.e. the distance moved); otherwise returns NR_HUGE.

Definition at line 339 of file snap.cpp.

References NR::rot90(), and sp_intersector_line_intersection().

{
    NR::Point const req0(req);
    /* Implement "move from req0 by some multiple of mv" as "dot product with something
       orthogonal to mv remains unchanged". */
    NR::Point const n2(NR::rot90(mv));
    NR::Coord const d2 = dot(n2, req);
    if (sp_intersector_line_intersection(n2, d2, n, d, req) == intersects) {
        return L2(req - req0);
    } else {
        return NR_HUGE;
    }
}


Generated by  Doxygen 1.6.0   Back to index