33 #include <wx/gdicmn.h> 48 const wxPoint& aTestPoint );
62 const wxPoint &a_p1_l2,
const wxPoint &a_p2_l2,
63 wxPoint* aIntersectionPoint =
nullptr );
101 void RotatePoint(
double *pX,
double *pY,
double cx,
double cy,
double angle );
113 const wxPoint
GetArcCenter(
const wxPoint& aStart,
const wxPoint& aMid,
const wxPoint& aEnd );
137 return hypot( vector.x, vector.y );
143 return hypot( vector.x, vector.y );
152 const wxPoint &linePointB,
153 const wxPoint &referencePoint )
160 return fabs( ( static_cast<double>( linePointB.x - linePointA.x ) *
161 static_cast<double>( linePointA.y - referencePoint.y ) -
162 static_cast<double>( linePointA.x - referencePoint.x ) *
163 static_cast<double>( linePointB.y - linePointA.y) )
172 inline bool HitTestPoints(
const wxPoint &pointA,
const wxPoint &pointB,
double threshold )
174 wxPoint vectorAB = pointB - pointA;
178 double sqdistance = (double)vectorAB.x * vectorAB.x + (
double)vectorAB.y * vectorAB.y;
180 return sqdistance < threshold * threshold;
186 inline double CrossProduct(
const wxPoint &vectorA,
const wxPoint &vectorB )
189 return (
double)vectorA.x * vectorB.y - (double)vectorA.y * vectorB.x;
200 bool TestSegmentHit(
const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd,
int aDist );
209 inline double GetLineLength(
const wxPoint& aPointA,
const wxPoint& aPointB )
212 return hypot( aPointA.x - aPointB.x,
213 aPointA.y - aPointB.y );
217 inline double DEG2RAD(
double deg ) {
return deg * M_PI / 180.0; }
218 inline double RAD2DEG(
double rad ) {
return rad * 180.0 / M_PI; }
221 inline double DECIDEG2RAD(
double deg ) {
return deg * M_PI / 1800.0; }
222 inline double RAD2DECIDEG(
double rad ) {
return rad * 1800.0 / M_PI; }
231 while( Angle < -3600 )
233 while( Angle > 3600 )
242 while( Angle <= -3600 )
244 while( Angle >= 3600 )
255 while( Angle <= -3600 )
269 while( Angle >= 3600 )
286 while( Angle >= 360.0 )
301 Angle += (2 * M_PI );
302 while( Angle >= ( 2 * M_PI ) )
303 Angle -= ( 2 * M_PI );
311 while( Angle < aMin )
313 while( Angle >= aMax )
321 template <
class T,
class T2>
inline T
AddAngles( T a1, T2 a2 )
334 while( Angle >= 3600 )
348 while( Angle < -900 )
364 while( Angle <= -1800 )
366 while( Angle > 1800 )
386 double end = aEndAngle;
388 if( aStartAngle > aEndAngle )
391 return aStartAngle < 360.0 && end > 360.0;
404 double end = aEndAngle;
406 if( aStartAngle > aEndAngle )
409 return aStartAngle < 180.0 && end > 180.0;
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
T NormalizeAngleNeg(T Angle)
Normalize angle to be in the 0.0 .
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
double GetArcAngle(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Returns the subtended angle for a given arc.
T NormalizeAngle360Max(T Angle)
Normalize angle to be >=-360.0 and <= 360.0 Angle can be equal to -360 or +360.
double RAD2DEG(double rad)
VECTOR2 defines a general 2D-vector/point.
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Test if aTestPoint is on line defined by aSegStart and aSegEnd.
double RAD2DECIDEG(double rad)
T NormalizeAngle90(T Angle)
Normalize angle to be in the -90.0 .. 90.0 range.
void NORMALIZE_ANGLE_DEGREES_POS(double &Angle)
void NORMALIZE_ANGLE_180(T &Angle)
void RotatePoint(int *pX, int *pY, double angle)
void NORMALIZE_ANGLE_POS(T &Angle)
double NormalizeAngleRadiansPos(double Angle)
void NORMALIZE_ANGLE_90(T &Angle)
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
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.
T NormalizeAngle180(T Angle)
Normalize angle to be in the -180.0 .. 180.0 range.
double NormalizeAngleDegreesPos(double Angle)
Normalize angle to be in the 0.0 .
T AddAngles(T a1, T2 a2)
Add two angles (keeping the result normalized). T2 is here.
bool InterceptsPositiveX(double aStartAngle, double aEndAngle)
Test if an arc from aStartAngle to aEndAngle crosses the positive X axis (0 degrees).
double CrossProduct(const wxPoint &vectorA, const wxPoint &vectorB)
Determine the cross product.
void NEGATE_AND_NORMALIZE_ANGLE_POS(T &Angle)
double cosdecideg(double r, double a)
Circle generation utility: computes r * cos(a) Where a is in decidegrees, not in radians.
double sindecideg(double r, double a)
Circle generation utility: computes r * sin(a) Where a is in decidegrees, not in radians.
T NegateAndNormalizeAnglePos(T Angle)
double DEG2RAD(double deg)
bool InterceptsNegativeX(double aStartAngle, double aEndAngle)
Test if an arc from aStartAngle to aEndAngle crosses the negative X axis (180 degrees).
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
bool HitTestPoints(const wxPoint &pointA, const wxPoint &pointB, double threshold)
Test, if two points are near each other.
double DECIDEG2RAD(double deg)
double NormalizeAngleDegrees(double Angle, double aMin, double aMax)
Normalize angle to be aMin < angle <= aMax angle is in degrees.
double ArcTangente(int dy, int dx)
const VECTOR2I GetArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
T NormalizeAngle360Min(T Angle)
Normalize angle to be > -360.0 and < 360.0 Angle equal to -360 or +360 are set to 0.
double DistanceLinePoint(const wxPoint &linePointA, const wxPoint &linePointB, const wxPoint &referencePoint)
Compute the distance between a line and a reference point Reference: http://mathworld....