• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kig

  • sources
  • kde-4.12
  • kdeedu
  • kig
  • misc
misc/common.h
Go to the documentation of this file.
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 <qrect.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 QString& caption, const QString& label, double value,
44  QWidget* 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 ) {}
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 
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
calcBorderPoints
void calcBorderPoints(Coordinate &p1, Coordinate &p2, const Rect &r)
this sets p1 and p2 to p1' and p2' so that p1'p2' is the same line as p1p2, and so that p1' and p2' a...
Definition: common.cpp:82
calcPointOnParallel
Coordinate calcPointOnParallel(const LineData &l, const Coordinate &t)
this returns a point, so that the line through point t and the point returned is parallel with the li...
Definition: common.cpp:47
calcPointProjection
const Coordinate calcPointProjection(const Coordinate &p, const LineData &l)
this calculates the perpendicular projection of point p on line ab...
Definition: common.cpp:295
LineData::isOrthogonalTo
bool isOrthogonalTo(const LineData &l) const
Return true if this line is orthogonal to l.
Definition: common.cpp:474
LineData
Simple class representing a line.
Definition: misc/common.h:49
LineData::dir
const Coordinate dir() const
The direction of the line.
Definition: misc/common.h:72
LineData::b
Coordinate b
Another point on the line.
Definition: misc/common.h:68
lineInRect
bool lineInRect(const Rect &r, const Coordinate &a, const Coordinate &b, const int width, const ObjectImp *imp, const KigWidget &w)
Is the line, segment, ray or vector inside r ? We need the imp to distinguish between rays...
Definition: common.cpp:401
calcDistancePointLine
double calcDistancePointLine(const Coordinate &p, const LineData &l)
calc the distance of point p to the line through a and b...
Definition: common.cpp:302
isOnRay
bool isOnRay(const Coordinate &o, const Coordinate &a, const Coordinate &b, const double fault)
Definition: common.cpp:226
Rect
This file is part of Kig, a KDE program for Interactive Geometry...
Definition: rect.h:34
QWidget
isOnArc
bool isOnArc(const Coordinate &o, const Coordinate &c, const double r, const double sa, const double a, const double fault)
Definition: common.cpp:238
kigAbs
T kigAbs(const T &a)
Definition: misc/common.h:267
double_inf
const double double_inf
Definition: common.cpp:509
Coordinate
The Coordinate class is the basic class representing a 2D location by its x and y components...
Definition: coordinate.h:33
LineData::LineData
LineData()
Default constructor.
Definition: misc/common.h:56
calcIntersectionPoint
Coordinate calcIntersectionPoint(const LineData &l, const LineData &m)
this calcs the point where the lines l and m intersect...
Definition: common.cpp:57
calcCenter
const Coordinate calcCenter(const Coordinate &a, const Coordinate &b, const Coordinate &c)
This function calculates the center of the circle going through the three given points.
Definition: common.cpp:366
rect.h
calcPointOnPerpend
Coordinate calcPointOnPerpend(const LineData &l, const Coordinate &t)
this returns a point, so that the line through point t and the point returned is perpendicular to the...
Definition: common.cpp:37
kigMax
T kigMax(const T &a, const T &b)
Definition: misc/common.h:261
getDoubleFromUser
double getDoubleFromUser(const QString &caption, const QString &label, double value, QWidget *parent, bool *ok, double min, double max, int decimals)
Here, we define some algorithms which we need in various places...
Definition: common.cpp:349
LineData::a
Coordinate a
One point on the line.
Definition: misc/common.h:64
KigWidget
This class is the real widget showing the document.
Definition: kig_view.h:50
calcRotatedPoint
Coordinate calcRotatedPoint(const Coordinate &a, const Coordinate &c, const double arc)
This calcs the rotation of point a around point c by arc arc.
Definition: common.cpp:315
LineData::isParallelTo
bool isParallelTo(const LineData &l) const
Return true if this line is parallel to l.
Definition: common.cpp:459
kigMin
T kigMin(const T &a, const T &b)
Definition: misc/common.h:255
calcCircleLineIntersect
const Coordinate calcCircleLineIntersect(const Coordinate &c, const double sqr, const LineData &l, int side)
this calcs the intersection points of the circle with center c and radius sqrt( r )...
Definition: common.cpp:262
LineData::LineData
LineData(const Coordinate &na, const Coordinate &nb)
Constructor.
Definition: misc/common.h:60
isOnSegment
bool isOnSegment(const Coordinate &o, const Coordinate &a, const Coordinate &b, const double fault)
is o on the segment defined by point a and point b ? this calls isOnLine(), but also checks if o is "...
Definition: common.cpp:212
isOnLine
bool isOnLine(const Coordinate &o, const Coordinate &a, const Coordinate &b, const double fault)
is o on the line defined by point a and point b ? fault is the allowed difference...
Definition: common.cpp:188
isSingular
bool isSingular(const double &a, const double &b, const double &c, const double &d)
test if a 2x2 matrix is singular (relatively to the norm of the two row vectors)
Definition: common.cpp:495
calcMirrorPoint
const Coordinate calcMirrorPoint(const LineData &l, const Coordinate &p)
calc the mirror point of p over the line l
Definition: common.cpp:250
calcCircleRadicalStartPoint
Coordinate calcCircleRadicalStartPoint(const Coordinate &ca, const Coordinate &cb, double sqra, double sqrb)
Definition: common.cpp:335
calcArcLineIntersect
const Coordinate calcArcLineIntersect(const Coordinate &c, const double sqr, const double sa, const double angle, const LineData &l, int side)
this calcs the intersection points of the arc with center c, radius sqrt( r ), start angle sa and ang...
Definition: common.cpp:285
areCollinear
bool areCollinear(const Coordinate &p1, const Coordinate &p2, const Coordinate &p3)
test collinearity of three points
Definition: common.cpp:489
kigSgn
int kigSgn(const T &a)
Definition: misc/common.h:273
calcRayBorderPoints
void calcRayBorderPoints(const Coordinate &a, Coordinate &b, const Rect &r)
this does the same as the above function, but only for b.
Definition: common.cpp:131
operator==
bool operator==(const LineData &l, const LineData &r)
Equality.
Definition: common.cpp:454
ObjectImp
The ObjectImp class represents the behaviour of an object after it is calculated. ...
Definition: object_imp.h:226
coordinate.h
LineData::length
double length() const
The length from a to b.
Definition: misc/common.h:76
test_threshold
const double test_threshold
Definition: common.cpp:510
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kig

Skip menu "kig"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal