Logo Search packages:      
Sourcecode: inkscape version File versions

bool vectors_are_clockwise ( NR::Point  A,
NR::Point  B,
NR::Point  C 
)

Todo:
FIXME: This can be done using linear operations, more stably and faster. method: transform A and C into B's space, A should be negative and B should be positive in the orthogonal component. I think this is equivalent to dot(A, rot90(B))*dot(C, rot90(B)) == -1. -- njh

Definition at line 825 of file sp-offset.cpp.

References Geom::dot(), Geom::rot90(), and NR::rot90().

Referenced by sp_offset_distance_to_original().

{
    using NR::rot90;
    double ab_s = dot(A, rot90(B));
    double ab_c = dot(A, B);
    double bc_s = dot(B, rot90(C));
    double bc_c = dot(B, C);
    double ca_s = dot(C, rot90(A));
    double ca_c = dot(C, A);

    double ab_a = acos (ab_c);
    if (ab_c <= -1.0)
        ab_a = M_PI;
    if (ab_c >= 1.0)
        ab_a = 0;
    if (ab_s < 0)
        ab_a = 2 * M_PI - ab_a;
    double bc_a = acos (bc_c);
    if (bc_c <= -1.0)
        bc_a = M_PI;
    if (bc_c >= 1.0)
        bc_a = 0;
    if (bc_s < 0)
        bc_a = 2 * M_PI - bc_a;
    double ca_a = acos (ca_c);
    if (ca_c <= -1.0)
        ca_a = M_PI;
    if (ca_c >= 1.0)
        ca_a = 0;
    if (ca_s < 0)
        ca_a = 2 * M_PI - ca_a;

    double lim = 2 * M_PI - ca_a;

    if (ab_a < lim)
        return true;
    return false;
}


Generated by  Doxygen 1.6.0   Back to index