Kig Python Scripting API Documentation

common.h
1 
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 
33 class ObjectImp;
34 class KigWidget;
35 
36 extern const double double_inf;
37 
43 double getDoubleFromUser( const TQString& caption, const TQString& label, double value,
44  TQWidget* parent, bool* ok, double min, double max, int decimals );
45 
49 class LineData {
50 public:
56  LineData() : a(), b() {}
60  LineData( const Coordinate& na, const Coordinate& nb ) : a( na ), b( nb ) {}
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 
92 bool 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 
139 const Coordinate calcCircleLineIntersect( const Coordinate& c,
140  const double sqr,
141  const LineData& l,
142  int side );
143 
153 const Coordinate calcArcLineIntersect( const Coordinate& c, const double sqr,
154  const double sa, const double angle,
155  const LineData& l, int side );
156 
161 const Coordinate calcPointProjection( const Coordinate& p,
162  const LineData& l );
163 
167 double calcDistancePointLine( const Coordinate& p,
168  const LineData& l );
169 
174 void calcBorderPoints( Coordinate& p1, Coordinate& p2, const Rect& r );
178 void calcBorderPoints( double& xa, double& xb, double& ya, double& yb, const Rect& r);
182 const LineData calcBorderPoints( const LineData& l, const Rect& r );
183 
187 void calcRayBorderPoints( const Coordinate& a, Coordinate& b, const Rect& r );
188 
193 const Coordinate calcCenter(
194  const Coordinate& a, const Coordinate& b, const Coordinate& c );
195 
199 void calcRayBorderPoints( const double xa, const double xb, double& ya,
200  double& yb, const Rect& r );
201 
205 const Coordinate calcMirrorPoint( const LineData& l,
206  const Coordinate& p );
207 
211 bool areCollinear( const Coordinate& p1, const Coordinate& p2,
212  const Coordinate& p3 );
213 
218 bool isSingular( const double& a, const double& b,
219  const double& c, const double& d );
220 
225 bool isOnLine( const Coordinate& o, const Coordinate& a,
226  const Coordinate& b, const double fault );
227 
233 bool isOnSegment( const Coordinate& o, const Coordinate& a,
234  const Coordinate& b, const double fault );
235 
236 bool isOnRay( const Coordinate& o, const Coordinate& a,
237  const Coordinate& b, const double fault );
238 
239 bool 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 
251 bool lineInRect( const Rect& r, const Coordinate& a, const Coordinate& b,
252  const int width, const ObjectImp* imp, const KigWidget& w );
253 
254 template <typename T>
255 T kigMin( const T& a, const T& b )
256 {
257  return a < b ? a : b;
258 }
259 
260 template <typename T>
261 T kigMax( const T& a, const T& b )
262 {
263  return a > b ? a : b;
264 }
265 
266 template <typename T>
267 T kigAbs( const T& a )
268 {
269  return a >= 0 ? a : -a;
270 }
271 
272 template <typename T>
273 int kigSgn( const T& a )
274 {
275  return a == 0 ? 0 : a > 0 ? +1 : -1;
276 }
277 
278 extern const double test_threshold;
279 
280 #endif
The Coordinate class is the basic class representing a 2D location by its x and y components.
Definition: coordinate.h:34
Simple class representing a line.
Definition: common.h:49
Coordinate b
Another point on the line.
Definition: common.h:68
const Coordinate dir() const
The direction of the line.
Definition: common.h:72
LineData(const Coordinate &na, const Coordinate &nb)
Constructor.
Definition: common.h:60
bool isOrthogonalTo(const LineData &l) const
Return true if this line is orthogonal to l.
Coordinate a
One point on the line.
Definition: common.h:64
double length() const
The length from a to b.
Definition: common.h:76
bool isParallelTo(const LineData &l) const
Return true if this line is parallel to l.
KDE Logo
This file is part of the documentation for tdelibs .
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Apr 8 2026 11:17:32 by doxygen 1.9.1 written by Dimitri van Heesch, © 1997-2001