src/corelib/tools/qline.cpp File Reference

#include "qline.h"
#include "qdebug.h"
#include "qdatastream.h"
#include <private/qnumeric_p.h>
#include <math.h>

Include dependency graph for qline.cpp:

Go to the source code of this file.

Defines

#define M_2PI   6.28318530717958647692528676655900576
#define SAME_SIGNS(a, b)   ((a) * (b) >= 0)

Functions

QDebug operator<< (QDebug d, const QLine &p)
static bool qt_linef_intersect (qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4)
QDebug operator<< (QDebug d, const QLineF &p)


Define Documentation

#define M_2PI   6.28318530717958647692528676655900576

Definition at line 230 of file qline.cpp.

Referenced by QLineF::angle().

#define SAME_SIGNS ( a,
 )     ((a) * (b) >= 0)

Definition at line 501 of file qline.cpp.

Referenced by qt_linef_intersect().


Function Documentation

QDebug operator<< ( QDebug  d,
const QLineF p 
)

Definition at line 625 of file qline.cpp.

00626 {
00627     d << "QLineF(" << p.p1() << "," << p.p2() << ")";
00628     return d;
00629 }

QDebug operator<< ( QDebug  d,
const QLine p 
)

Definition at line 184 of file qline.cpp.

00185 {
00186     d << "QLine(" << p.p1() << "," << p.p2() << ")";
00187     return d;
00188 }

static bool qt_linef_intersect ( qreal  x1,
qreal  y1,
qreal  x2,
qreal  y2,
qreal  x3,
qreal  y3,
qreal  x4,
qreal  y4 
) [static]

Definition at line 504 of file qline.cpp.

References SAME_SIGNS.

Referenced by QLineF::intersect().

00506 {
00507     qreal a1, a2, b1, b2, c1, c2; /* Coefficients of line eqns. */
00508     qreal r1, r2, r3, r4;         /* 'Sign' values */
00509 
00510     a1 = y2 - y1;
00511     b1 = x1 - x2;
00512     c1 = x2 * y1 - x1 * y2;
00513 
00514     r3 = a1 * x3 + b1 * y3 + c1;
00515     r4 = a1 * x4 + b1 * y4 + c1;
00516 
00517     if ( r3 != 0 && r4 != 0 && SAME_SIGNS( r3, r4 ))
00518         return false;
00519 
00520     a2 = y4 - y3;
00521     b2 = x3 - x4;
00522     c2 = x4 * y3 - x3 * y4;
00523 
00524     r1 = a2 * x1 + b2 * y1 + c2;
00525     r2 = a2 * x2 + b2 * y2 + c2;
00526 
00527     if ( r1 != 0 && r2 != 0 && SAME_SIGNS( r1, r2 ))
00528         return false;
00529 
00530     return true;
00531 }


Generated on Thu Mar 15 13:03:51 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1