common.h Source File (Kig Python Scripting API)

| # Kig Python Scripting API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members

common.h
1
20
21
22#ifndef KIG_MISC_COMMON_H
23#define KIG_MISC_COMMON_H
24
25#include "coordinate.h"
26#include "rect.h"
27
28#include <tqrect.h>
29
30#include <vector>
31#include <assert.h>
32
33class ObjectImp;
34class KigWidget;
35
36extern const double double_inf;
37
42
43double getDoubleFromUser( const TQString& caption, const TQString& label, double value,
44 TQWidget* parent, bool* ok, double min, double max, int decimals );
45
49 class LineData {
50public:
56 LineData() : a(), b() {}
60 LineData( const Coordinate& na, const Coordinate& nb ) : a( na ), b( nb ) {}
64 Coordinate a;
68 Coordinate b;
72 const Coordinate dir() const { return b - a; }
76 double length() const { return ( b - a ).length(); }
77
81 bool isParallelTo( const LineData& l ) const;
82
86 bool isOrthogonalTo( const LineData& l ) const;
87};
88
92bool operator==( const LineData& l, const LineData& r );
93
98 Coordinate calcRotatedPoint( const Coordinate& a, const Coordinate& c, const double arc );
99
104 Coordinate calcPointOnPerpend( const LineData& l, const Coordinate& t );
105
110 Coordinate calcPointOnPerpend( const Coordinate& dir, const Coordinate& t );
111
116 Coordinate calcPointOnParallel( const LineData& l, const Coordinate& t );
117
122 Coordinate calcPointOnParallel( const Coordinate& dir, const Coordinate& t );
123
124
128 Coordinate calcIntersectionPoint( const LineData& l, const LineData& m );
129
139const Coordinate calcCircleLineIntersect( const Coordinate& c,
140 const double sqr,
141 const LineData& l,
142 int side );
143
153const Coordinate calcArcLineIntersect( const Coordinate& c, const double sqr,
154 const double sa, const double angle,
155 const LineData& l, int side );
156
161const Coordinate calcPointProjection( const Coordinate& p,
162 const LineData& l );
163
167double calcDistancePointLine( const Coordinate& p,
168 const LineData& l );
169
174void calcBorderPoints( Coordinate& p1, Coordinate& p2, const Rect& r );
178void calcBorderPoints( double& xa, double& xb, double& ya, double& yb, const Rect& r);
182const LineData calcBorderPoints( const LineData& l, const Rect& r );
183
187void calcRayBorderPoints( const Coordinate& a, Coordinate& b, const Rect& r );
188
193const Coordinate calcCenter(
194 const Coordinate& a, const Coordinate& b, const Coordinate& c );
195
199void calcRayBorderPoints( const double xa, const double xb, double& ya,
200 double& yb, const Rect& r );
201
205const Coordinate calcMirrorPoint( const LineData& l,
206 const Coordinate& p );
207
211bool areCollinear( const Coordinate& p1, const Coordinate& p2,
212 const Coordinate& p3 );
213
218bool isSingular( const double& a, const double& b,
219 const double& c, const double& d );
220
225bool isOnLine( const Coordinate& o, const Coordinate& a,
226 const Coordinate& b, const double fault );
227
233bool isOnSegment( const Coordinate& o, const Coordinate& a,
234 const Coordinate& b, const double fault );
235
236bool isOnRay( const Coordinate& o, const Coordinate& a,
237 const Coordinate& b, const double fault );
238
239bool isOnArc( const Coordinate& o, const Coordinate& c, const double r,
240 const double sa, const double a, const double fault );
241
242 Coordinate calcCircleRadicalStartPoint( const Coordinate& ca,
243 const Coordinate& cb,
244 double sqra, double sqrb );
245
251bool lineInRect( const Rect& r, const Coordinate& a, const Coordinate& b,
252 const int width, const ObjectImp* imp, const KigWidget& w );
253
254template <typename T>
255T kigMin( const T& a, const T& b )
256{
257 return a < b ? a : b;
258}
259
260template <typename T>
261T kigMax( const T& a, const T& b )
262{
263 return a > b ? a : b;
264}
265
266template <typename T>
267T kigAbs( const T& a )
268{
269 return a >= 0 ? a : -a;
270}
271
272template <typename T>
273int kigSgn( const T& a )
274{
275 return a == 0 ? 0 : a > 0 ? +1 : -1;
276}
277
278extern const double test_threshold;
279
280#endif
Coordinate
The Coordinate class is the basic class representing a 2D location by its x and y components.
Definition coordinate.h:34
LineData
Simple class representing a line.
Definition common.h:49
LineData::b
Coordinate b
Another point on the line.
Definition common.h:68
LineData::dir
const Coordinate dir() const
The direction of the line.
Definition common.h:72
LineData::LineData
LineData(const Coordinate &na, const Coordinate &nb)
Constructor.
Definition common.h:60
LineData::isOrthogonalTo
bool isOrthogonalTo(const LineData &l) const
Return true if this line is orthogonal to l.
LineData::a
Coordinate a
One point on the line.
Definition common.h:64
LineData::length
double length() const
The length from a to b.
Definition common.h:76
LineData::isParallelTo
bool isParallelTo(const LineData &l) const
Return true if this line is parallel to l.
LineData::LineData
LineData()
Definition common.h:56
Object
The Object class represents the behaviour of an object after it is calculated.
Definition object_imp.h:219
This file is part of the documentation for tdelibs .
Documentation copyright © 1996-2002 the KDE developers.
Generated on by doxygen 1.16.1 written by Dimitri van Heesch, © 1997-2001