X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fgeom.cpp;h=e59b0f30233ae211b981c5986b3b98d2503c5c97;hb=03a65c733a473cd92d50132961d02c3910417f72;hp=2749d6d7d34fee19dc04d88f8c0a485a4f796468;hpb=6b15695578f07a3f72c4c9475c1a261a3021472a;p=inkscape.git diff --git a/src/geom.cpp b/src/geom.cpp index 2749d6d7d..e59b0f302 100644 --- a/src/geom.cpp +++ b/src/geom.cpp @@ -18,39 +18,40 @@ * * This function finds the intersection of the two lines (infinite) * defined by n0.X = d0 and x1.X = d1. The algorithm is as follows: - * To compute the intersection point use kramer's rule: + * To compute the intersection point use Cramer's rule: + * (see http://en.wikipedia.org/wiki/Cramer%27s_rule) * \verbatim * convert lines to form * ax + by = c * dx + ey = f - * + * * ( * e.g. a = (x2 - x1), b = (y2 - y1), c = (x2 - x1)*x1 + (y2 - y1)*y1 * ) - * + * * In our case we use: * a = n0.x d = n1.x * b = n0.y e = n1.y * c = d0 f = d1 - * + * * so: - * + * * adx + bdy = cd * adx + aey = af - * + * * bdy - aey = cd - af * (bd - ae)y = cd - af - * + * * y = (cd - af)/(bd - ae) - * + * * repeat for x and you get: - * + * * x = (fb - ce)/(bd - ae) \endverbatim - * + * * If the denominator (bd-ae) is 0 then the lines are parallel, if the - * numerators are then 0 then the lines coincide. + * numerators are then 0 then the lines coincide. * - * \todo Why not use existing but outcommented code below + * \todo Why not use existing but outcommented code below * (HAVE_NEW_INTERSECTOR_CODE)? */ IntersectorKind intersector_line_intersection(NR::Point const &n0, double const d0, @@ -69,12 +70,12 @@ IntersectorKind intersector_line_intersection(NR::Point const &n0, double const return PARALLEL; } } - + double Y = n0[NR::X] * d1 - n1[NR::X] * d0; - + result = NR::Point(X, Y) / denominator; - + return INTERSECTS; }