Searching...
No Matches
trigo.h File Reference
`#include <cmath>`
`#include <math/vector2d.h>`
`#include <geometry/eda_angle.h>`

Go to the source code of this file.

## Functions

bool IsPointOnSegment (const VECTOR2I &aSegStart, const VECTOR2I &aSegEnd, const VECTOR2I &aTestPoint)
Test if aTestPoint is on line defined by aSegStart and aSegEnd.

bool SegmentIntersectsSegment (const VECTOR2I &a_p1_l1, const VECTOR2I &a_p2_l1, const VECTOR2I &a_p1_l2, const VECTOR2I &a_p2_l2, VECTOR2I *aIntersectionPoint=nullptr)
Test if two lines intersect.

void RotatePoint (int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.

void RotatePoint (VECTOR2I &point, const EDA_ANGLE &aAngle)

void RotatePoint (int *pX, int *pY, int cx, int cy, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center cx, cy.

void RotatePoint (VECTOR2I &point, const VECTOR2I &centre, const EDA_ANGLE &aAngle)

void RotatePoint (double *pX, double *pY, const EDA_ANGLE &aAngle)
Calculate the new coord point point for a rotation center 0, 0.

void RotatePoint (VECTOR2D &point, const EDA_ANGLE &aAngle)

void RotatePoint (double *pX, double *pY, double cx, double cy, const EDA_ANGLE &aAngle)

void RotatePoint (VECTOR2D &point, const VECTOR2D &aCenter, const EDA_ANGLE &aAngle)

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 VECTOR2D CalcArcCenter (const VECTOR2D &aStart, const VECTOR2D &aMid, const VECTOR2D &aEnd)

const VECTOR2D CalcArcCenter (const VECTOR2D &aStart, const VECTOR2D &aEnd, const EDA_ANGLE &aAngle)

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.

bool TestSegmentHit (const VECTOR2I &aRefPoint, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.

template<class T >
NormalizeAnglePos (T Angle)
Normalize angle to be in the 0.0 .

template<class T >
void NORMALIZE_ANGLE_POS (T &Angle)

template<class T >
NormalizeAngle180 (T Angle)
Normalize angle to be in the -180.0 .

bool InterceptsPositiveX (double aStartAngle, double aEndAngle)
Test if an arc from aStartAngle to aEndAngle crosses the positive X axis (0 degrees).

bool InterceptsNegativeX (double aStartAngle, double aEndAngle)
Test if an arc from aStartAngle to aEndAngle crosses the negative X axis (180 degrees).

## ◆ CalcArcCenter() [1/3]

 const VECTOR2D CalcArcCenter ( const VECTOR2D & aStart, const VECTOR2D & aEnd, const EDA_ANGLE & aAngle )

Definition at line 333 of file trigo.cpp.

References ANGLE_0, ANGLE_180, ANGLE_360, ANGLE_90, VECTOR2< T >::Resize(), RotatePoint(), and EDA_ANGLE::Sin().

Referenced by CalcArcCenter().

## ◆ CalcArcCenter() [2/3]

 const VECTOR2D CalcArcCenter ( const VECTOR2D & aStart, const VECTOR2D & aMid, const VECTOR2D & aEnd )

Definition at line 369 of file trigo.cpp.

## ◆ CalcArcCenter() [3/3]

 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.

Parameters
 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).
Returns
The center of the circle.

Definition at line 521 of file trigo.cpp.

References CalcArcCenter(), KiROUND(), VECTOR2< T >::x, and VECTOR2< T >::y.

## ◆ CalcArcMid()

 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 behavior is undefined for semicircles (i.e. 180 degree arcs).

Parameters
 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.
Returns
The middle point of the arc.

Definition at line 209 of file trigo.cpp.

References ANGLE_180, and RotatePoint().

## ◆ InterceptsNegativeX()

 bool InterceptsNegativeX ( double aStartAngle, double aEndAngle )
inline

Test if an arc from aStartAngle to aEndAngle crosses the negative X axis (180 degrees).

Testing is performed in the quadrant 1 to quadrant 4 direction (counter-clockwise).

Parameters
 aStartAngle The arc start angle in degrees. aEndAngle The arc end angle in degrees.

Definition at line 207 of file trigo.h.

Referenced by BOOST_AUTO_TEST_CASE().

## ◆ InterceptsPositiveX()

 bool InterceptsPositiveX ( double aStartAngle, double aEndAngle )
inline

Test if an arc from aStartAngle to aEndAngle crosses the positive X axis (0 degrees).

Testing is performed in the quadrant 1 to quadrant 4 direction (counter-clockwise).

Parameters
 aStartAngle The arc start angle in degrees. aEndAngle The arc end angle in degrees.

Definition at line 189 of file trigo.h.

Referenced by BOOST_AUTO_TEST_CASE().

## ◆ IsPointOnSegment()

 bool IsPointOnSegment ( const VECTOR2I & aSegStart, const VECTOR2I & aSegEnd, const VECTOR2I & 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 only works for horizontal, vertical, and 45 degree line segments.

Parameters
 aSegStart The first point of the line segment. aSegEnd The second point of the line segment. aTestPoint The point to test.
Returns
true if the point is on the line segment.

Definition at line 89 of file trigo.cpp.

References VECTOR2< T >::x, and VECTOR2< T >::y.

## ◆ NORMALIZE_ANGLE_POS()

template<class T >
 void NORMALIZE_ANGLE_POS ( T & Angle )
inline

Definition at line 161 of file trigo.h.

References NormalizeAnglePos().

## ◆ NormalizeAngle180()

template<class T >
 T NormalizeAngle180 ( T Angle )
inline

Normalize angle to be in the -180.0 .

. 180.0 range.

Definition at line 170 of file trigo.h.

Referenced by DIALOG_COPPER_ZONE::AcceptOptions(), and PANEL_ZONE_PROPERTIES::AcceptOptions().

## ◆ NormalizeAnglePos()

template<class T >
 T NormalizeAnglePos ( T Angle )
inline

Normalize angle to be in the 0.0 .

. 360.0 range: angle is in 1/10 degrees.

Definition at line 152 of file trigo.h.

Referenced by NORMALIZE_ANGLE_POS().

inline

Definition at line 144 of file trigo.h.

Referenced by MapAnglesV6().

inline

Definition at line 141 of file trigo.h.

## ◆ RotatePoint() [1/8]

 void RotatePoint ( double * pX, double * pY, const EDA_ANGLE & aAngle )

Calculate the new coord point point for a rotation center 0, 0.

Definition at line 295 of file trigo.cpp.

## ◆ RotatePoint() [2/8]

 void RotatePoint ( double * pX, double * pY, double cx, double cy, const EDA_ANGLE & aAngle )

Definition at line 281 of file trigo.cpp.

References RotatePoint().

## ◆ RotatePoint() [4/8]

 void RotatePoint ( int * pX, int * pY, int cx, int cy, const EDA_ANGLE & aAngle )

Calculate the new point of coord coord pX, pY, for a rotation center cx, cy.

Definition at line 267 of file trigo.cpp.

References RotatePoint().

## ◆ RotatePoint() [5/8]

 void RotatePoint ( VECTOR2D & point, const EDA_ANGLE & aAngle )
inline

Definition at line 88 of file trigo.h.

References RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.

## ◆ RotatePoint() [6/8]

 void RotatePoint ( VECTOR2D & point, const VECTOR2D & aCenter, const EDA_ANGLE & aAngle )
inline

Definition at line 95 of file trigo.h.

References RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.

## ◆ RotatePoint() [7/8]

 void RotatePoint ( VECTOR2I & point, const EDA_ANGLE & aAngle )
inline

Definition at line 66 of file trigo.h.

References RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.

## ◆ RotatePoint() [8/8]

 void RotatePoint ( VECTOR2I & point, const VECTOR2I & centre, const EDA_ANGLE & aAngle )
inline

Definition at line 77 of file trigo.h.

References RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.

## ◆ SegmentIntersectsSegment()

 bool SegmentIntersectsSegment ( const VECTOR2I & a_p1_l1, const VECTOR2I & a_p2_l1, const VECTOR2I & a_p1_l2, const VECTOR2I & a_p2_l2, VECTOR2I * aIntersectionPoint = `nullptr` )

Test if two lines intersect.

Parameters
 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
Returns
bool true if the two segments defined by four points intersect. (i.e. if the 2 segments have at least a common point)

Definition at line 107 of file trigo.cpp.

References KiROUND(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by BOX2< Vec >::Intersects().

## ◆ TestSegmentHit()

 bool TestSegmentHit ( const VECTOR2I & aRefPoint, const VECTOR2I & aStart, const VECTOR2I & aEnd, int aDist )

Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.

Parameters
 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

Definition at line 175 of file trigo.cpp.

References std::abs(), delta, SEG::Square(), SEG::SquaredDistance(), VECTOR2< T >::x, and VECTOR2< T >::y.