32#include <math/vector2d.h>
63 wxPoint* aIntersectionPoint =
nullptr );
69void RotatePoint(
int *pX,
int *pY,
double angle );
75void RotatePoint(
int *pX,
int *pY,
int cx,
int cy,
double angle );
80inline void RotatePoint(
wxPoint* point,
double angle )
82 RotatePoint( &point->x, &point->y, angle );
85inline void RotatePoint(
VECTOR2I& point,
double angle )
87 RotatePoint( &point.x, &point.y, angle );
95void RotatePoint(
wxPoint *point,
const wxPoint & centre,
double angle );
97void RotatePoint(
double *pX,
double *pY,
double angle );
99void RotatePoint(
double *pX,
double *pY,
double cx,
double cy,
double angle );
131 bool aMinArcAngle =
true );
141double ArcTangente(
int dy,
int dx );
149 return hypot( vector.x, vector.y );
155 return hypot( vector.x, vector.y );
165 const wxPoint& referencePoint )
172 return fabs( (
static_cast<double>( linePointB.x - linePointA.x ) *
173 static_cast<double>( linePointA.y - referencePoint.y ) -
174 static_cast<double>( linePointA.x - referencePoint.x ) *
175 static_cast<double>( linePointB.y - linePointA.y) )
186 wxPoint vectorAB = pointB - pointA;
190 double sqdistance = (double)vectorAB.x * vectorAB.x + (
double)vectorAB.y * vectorAB.y;
192 return sqdistance < threshold * threshold;
201 return (
double)vectorA.x * vectorB.y - (double)vectorA.y * vectorB.x;
225 return hypot( aPointA.x - aPointB.x, aPointA.y - aPointB.y );
229inline double DEG2RAD(
double deg ) {
return deg * M_PI / 180.0; }
230inline double RAD2DEG(
double rad ) {
return rad * 180.0 / M_PI; }
233inline double DECIDEG2RAD(
double deg ) {
return deg * M_PI / 1800.0; }
234inline double RAD2DECIDEG(
double rad ) {
return rad * 1800.0 / M_PI; }
243 while( Angle < -3600 )
246 while( Angle > 3600 )
256 while( Angle <= -3600 )
259 while( Angle >= 3600 )
270 while( Angle <= -3600 )
285 while( Angle >= 3600 )
290template <
class T>
inline void NORMALIZE_ANGLE_POS( T& Angle )
302 while( Angle >= 360.0 )
309inline void NORMALIZE_ANGLE_DEGREES_POS(
double& Angle )
315inline double NormalizeAngleRadiansPos(
double Angle )
318 Angle += (2 * M_PI );
320 while( Angle >= ( 2 * M_PI ) )
321 Angle -= ( 2 * M_PI );
329 while( Angle < aMin )
332 while( Angle >= aMax )
341template <
class T,
class T2>
inline T
AddAngles( T a1, T2 a2 )
344 NORMALIZE_ANGLE_POS( a1 );
349template <
class T>
inline T NegateAndNormalizeAnglePos( T Angle )
356 while( Angle >= 3600 )
362template <
class T>
inline void NEGATE_AND_NORMALIZE_ANGLE_POS( T& Angle )
364 Angle = NegateAndNormalizeAnglePos( Angle );
371 while( Angle < -900 )
380template <
class T>
inline void NORMALIZE_ANGLE_90( T& Angle )
389 while( Angle <= -1800 )
392 while( Angle > 1800 )
398template <
class T>
inline void NORMALIZE_ANGLE_180( T& Angle )
413 double end = aEndAngle;
415 if( aStartAngle > aEndAngle )
418 return aStartAngle < 360.0 && end > 360.0;
431 double end = aEndAngle;
433 if( aStartAngle > aEndAngle )
436 return aStartAngle < 180.0 && end > 180.0;
445 return r * sin( DECIDEG2RAD( a ) );
454 return r * cos( DECIDEG2RAD( a ) );
Definition wx_compat.h:40
Definition wx_compat.h:64
bool SegmentIntersectsSegment(const wxPoint &a_p1_l1, const wxPoint &a_p2_l1, const wxPoint &a_p1_l2, const wxPoint &a_p2_l2, wxPoint *aIntersectionPoint=nullptr)
Test if two lines intersect.
Definition trigo.cpp:61
double NormalizeAngleDegrees(double Angle, double aMin, double aMax)
Normalize angle to be aMin < angle <= aMax angle is in degrees.
Definition trigo.h:327
const VECTOR2I CalcArcMid(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, bool aMinArcAngle=true)
Return the middle point of an arc, half-way between aStart and aEnd.
Definition trigo.cpp:163
double CrossProduct(const wxPoint &vectorA, const wxPoint &vectorB)
Determine the cross product.
Definition trigo.h:198
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Test if aTestPoint is on line defined by aSegStart and aSegEnd.
Definition trigo.cpp:42
double DistanceLinePoint(const wxPoint &linePointA, const wxPoint &linePointB, const wxPoint &referencePoint)
Compute the distance between a line and a reference point Reference: http://mathworld....
Definition trigo.h:163
double CalcArcAngle(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Return the subtended angle for a given arc.
Definition trigo.cpp:567
bool InterceptsPositiveX(double aStartAngle, double aEndAngle)
Test if an arc from aStartAngle to aEndAngle crosses the positive X axis (0 degrees).
Definition trigo.h:411
T NormalizeAngle360Max(T Angle)
Normalize angle to be >=-360.0 and <= 360.0 Angle can be equal to -360 or +360.
Definition trigo.h:241
T NormalizeAngleNeg(T Angle)
Normalize angle to be in the 0.0 .. -360.0 range: angle is in 1/10 degrees.
Definition trigo.h:268
double NormalizeAngleDegreesPos(double Angle)
Normalize angle to be in the 0.0 .. 360.0 range: angle is in degrees.
Definition trigo.h:297
bool HitTestPoints(const wxPoint &pointA, const wxPoint &pointB, double threshold)
Test, if two points are near each other.
Definition trigo.h:184
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition trigo.h:146
bool InterceptsNegativeX(double aStartAngle, double aEndAngle)
Test if an arc from aStartAngle to aEndAngle crosses the negative X axis (180 degrees).
Definition trigo.h:429
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .. 360.0 range: angle is in 1/10 degrees.
Definition trigo.h:281
T NormalizeAngle360Min(T Angle)
Normalize angle to be > -360.0 and < 360.0 Angle equal to -360 or +360 are set to 0.
Definition trigo.h:254
double sindecideg(double r, double a)
Circle generation utility: computes r * sin(a) Where a is in decidegrees, not in radians.
Definition trigo.h:443
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition trigo.h:222
bool TestSegmentHit(const wxPoint &aRefPoint, const wxPoint &aStart, const wxPoint &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
Definition trigo.cpp:129
T NormalizeAngle180(T Angle)
Normalize angle to be in the -180.0 .. 180.0 range.
Definition trigo.h:387
const VECTOR2I CalcArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
Definition trigo.cpp:525
T NormalizeAngle90(T Angle)
Normalize angle to be in the -90.0 .. 90.0 range.
Definition trigo.h:369
double cosdecideg(double r, double a)
Circle generation utility: computes r * cos(a) Where a is in decidegrees, not in radians.
Definition trigo.h:452
T AddAngles(T a1, T2 a2)
Add two angles (keeping the result normalized). T2 is here.
Definition trigo.h:341