Horizon
|
Trigonometric and geometric basic functions. More...
#include <limits>
#include <stdlib.h>
#include <type_traits>
#include <geometry/seg.h>
#include <math/util.h>
#include <math/vector2d.h>
#include <trigo.h>
Functions | |
bool | IsPointOnSegment (const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint) |
Test if aTestPoint is on line defined by aSegStart and aSegEnd. | |
bool | SegmentIntersectsSegment (const wxPoint &a_p1_l1, const wxPoint &a_p2_l1, const wxPoint &a_p1_l2, const wxPoint &a_p2_l2, wxPoint *aIntersectionPoint) |
Test if two lines intersect. | |
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. | |
const VECTOR2I | CalcArcMid (const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, bool aMinArcAngle) |
Return the middle point of an arc, half-way between aStart and aEnd. | |
double | ArcTangente (int dy, int dx) |
void | RotatePoint (int *pX, int *pY, double angle) |
void | RotatePoint (int *pX, int *pY, int cx, int cy, double angle) |
void | RotatePoint (wxPoint *point, const wxPoint ¢re, double angle) |
void | RotatePoint (VECTOR2I &point, const VECTOR2I ¢re, double angle) |
void | RotatePoint (double *pX, double *pY, double cx, double cy, double angle) |
void | RotatePoint (double *pX, double *pY, double angle) |
const wxPoint | CalcArcCenter (const VECTOR2I &aStart, const VECTOR2I &aEnd, double aAngle) |
const VECTOR2D | CalcArcCenter (const VECTOR2D &aStart, const VECTOR2D &aMid, const VECTOR2D &aEnd) |
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. | |
const wxPoint | CalcArcCenter (const wxPoint &aStart, const wxPoint &aMid, const wxPoint &aEnd) |
double | CalcArcAngle (const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd) |
Return the subtended angle for a given arc. | |
Trigonometric and geometric basic functions.
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.
aStart | The starting point of the circle (equivalent to aEnd) |
aMid | The point on the arc, half-way between aStart and aEnd |
aEnd | The ending point of the circle (equivalent to aStart) |
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.
There are two possible solutions which can be found by toggling aMinArcAngle. The behaviour is undefined for semicircles (i.e. 180 degree arcs).
aStart | The starting point of the arc (for calculating the radius) |
aEnd | The end point of the arc (for determining the arc angle) |
aCenter | The center point of the arc |
aMinArcAngle | If true, returns the point that results in the smallest arc angle. |
bool IsPointOnSegment | ( | const wxPoint & | aSegStart, |
const wxPoint & | aSegEnd, | ||
const wxPoint & | aTestPoint | ||
) |
Test if aTestPoint is on line defined by aSegStart and aSegEnd.
This function is faster than TestSegmentHit() because aTestPoint should be exactly on the line. This works fine only for H, V and 45 degree line segments.
aSegStart | The first point of the line segment. |
aSegEnd | The second point of the line segment. |
aTestPoint | The point to test. |
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.
a_p1_l1 | The first point of the first line. |
a_p2_l1 | The second point of the first line. |
a_p1_l2 | The first point of the second line. |
a_p2_l2 | The second point of the second line. |
aIntersectionPoint | is filled with the intersection point if it exists |
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.
aRefPoint | = reference point to test |
aStart | is the first end-point of the line segment |
aEnd | is the second end-point of the line segment |
aDist | = maximum distance for hit |