2011-09-20 13:57:40 +00:00
|
|
|
/**
|
|
|
|
* @file trigo.h
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#ifndef TRIGO_H
|
|
|
|
#define TRIGO_H
|
|
|
|
|
|
|
|
|
2011-09-20 13:57:40 +00:00
|
|
|
/*
|
|
|
|
* Calculate the new point of coord coord pX, pY,
|
|
|
|
* for a rotation center 0, 0, and angle in (1 / 10 degree)
|
|
|
|
*/
|
2011-12-14 04:29:25 +00:00
|
|
|
void RotatePoint( int *pX, int *pY, double angle );
|
2011-09-20 13:57:40 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate the new point of coord coord pX, pY,
|
|
|
|
* for a rotation center cx, cy, and angle in (1 / 10 degree)
|
|
|
|
*/
|
2011-12-14 04:29:25 +00:00
|
|
|
void RotatePoint( int *pX, int *pY, int cx, int cy, double angle );
|
2011-09-20 13:57:40 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculates the new coord point point
|
|
|
|
* for a rotation angle in (1 / 10 degree)
|
|
|
|
*/
|
2012-02-19 04:02:19 +00:00
|
|
|
static inline void RotatePoint( wxPoint* point, double angle )
|
|
|
|
{
|
|
|
|
RotatePoint( &point->x, &point->y, angle );
|
|
|
|
}
|
2011-09-20 13:57:40 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculates the new coord point point
|
|
|
|
* for a center rotation center and angle in (1 / 10 degree)
|
|
|
|
*/
|
2011-12-14 04:29:25 +00:00
|
|
|
void RotatePoint( wxPoint *point, const wxPoint & centre, double angle );
|
2011-09-20 13:57:40 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
void RotatePoint( double *pX, double *pY, double angle );
|
2011-09-20 13:57:40 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
void RotatePoint( double *pX, double *pY, double cx, double cy, double angle );
|
2009-06-13 17:06:07 +00:00
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
/* Return the arc tangent of 0.1 degrees coord vector dx, dy
|
|
|
|
* between -1800 and 1800
|
|
|
|
* Equivalent to atan2 (but faster for calculations if
|
|
|
|
* the angle is 0 to -1800, or + - 900
|
|
|
|
*/
|
2009-06-13 17:06:07 +00:00
|
|
|
int ArcTangente( int dy, int dx );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-02-04 17:46:12 +00:00
|
|
|
//! @brief Compute the distance between a line and a reference point
|
|
|
|
//! Reference: http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html
|
|
|
|
//! @param linePointA Point on line
|
|
|
|
//! @param linePointB Point on line
|
|
|
|
//! @param referencePoint Reference point
|
2011-03-25 19:16:05 +00:00
|
|
|
double DistanceLinePoint( wxPoint linePointA, wxPoint linePointB, wxPoint referencePoint );
|
2010-02-04 17:46:12 +00:00
|
|
|
|
|
|
|
//! @brief Euclidean norm of a 2D vector
|
|
|
|
//! @param vector Two-dimensional vector
|
|
|
|
//! @return Euclidean norm of the vector
|
2011-03-25 19:16:05 +00:00
|
|
|
double EuclideanNorm( wxPoint vector );
|
2010-02-04 17:46:12 +00:00
|
|
|
|
|
|
|
//! @brief Test, if two points are near each other
|
|
|
|
//! @param pointA First point
|
|
|
|
//! @param pointB Second point
|
|
|
|
//! @param threshold The maximum distance
|
|
|
|
//! @return True or false
|
2011-03-25 19:16:05 +00:00
|
|
|
bool HitTestPoints( wxPoint pointA, wxPoint pointB, double threshold );
|
2010-02-04 17:46:12 +00:00
|
|
|
|
|
|
|
//! @brief Determine the cross product
|
|
|
|
//! @param vectorA Two-dimensional vector
|
|
|
|
//! @param vectorB Two-dimensional vector
|
2012-12-27 16:42:41 +00:00
|
|
|
double CrossProduct( wxPoint vectorA, wxPoint vectorB );
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-11-12 16:59:16 +00:00
|
|
|
/**
|
|
|
|
* Function TestSegmentHit
|
2009-06-13 17:06:07 +00:00
|
|
|
* test for hit on line segment
|
|
|
|
* i.e. cursor within a given distance from segment
|
|
|
|
* @param aRefPoint = cursor (point to test) coords
|
|
|
|
* @param aStart is the first end-point of the line segment
|
|
|
|
* @param aEnd is the second end-point of the line segment
|
|
|
|
* @param aDist = maximum distance for hit
|
|
|
|
*/
|
2011-03-25 19:16:05 +00:00
|
|
|
bool TestSegmentHit( wxPoint aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist );
|
2009-06-13 17:06:07 +00:00
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
/**
|
|
|
|
* Function GetLineLength
|
|
|
|
* returns the length of a line segment defined by \a aPointA and \a aPointB.
|
|
|
|
* @return Length of a line.
|
|
|
|
*/
|
|
|
|
double GetLineLength( const wxPoint& aPointA, const wxPoint& aPointB );
|
2010-02-04 17:46:12 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#endif
|