Cleanup math_for_graphic code
This commit is contained in:
parent
dfdd2cfdbf
commit
90a6daa722
|
@ -387,8 +387,8 @@ bool BOARD::TestAreaIntersections( ZONE_CONTAINER* area_to_test )
|
|||
yf2 = poly2->GetY( is2 );
|
||||
}
|
||||
|
||||
int n_int = FindSegmentIntersections( xi1, yi1, xf1, yf1, STRAIGHT,
|
||||
xi2, yi2, xf2, yf2, STRAIGHT );
|
||||
int n_int = FindSegmentIntersections( xi1, yi1, xf1, yf1,
|
||||
xi2, yi2, xf2, yf2 );
|
||||
if( n_int )
|
||||
return true;
|
||||
}
|
||||
|
@ -498,8 +498,8 @@ int BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_
|
|||
yf2 = poly2->GetY( is2 );
|
||||
}
|
||||
|
||||
int n_int = FindSegmentIntersections( xi1, yi1, xf1, yf1, STRAIGHT,
|
||||
xi2, yi2, xf2, yf2, STRAIGHT );
|
||||
int n_int = FindSegmentIntersections( xi1, yi1, xf1, yf1,
|
||||
xi2, yi2, xf2, yf2 );
|
||||
if( n_int )
|
||||
{
|
||||
bInt = true;
|
||||
|
@ -844,10 +844,8 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E
|
|||
int x, y;
|
||||
|
||||
int d = GetClearanceBetweenSegments( bx1, by1, bx2, by2,
|
||||
STRAIGHT,
|
||||
0,
|
||||
ax1, ay1, ax2, ay2,
|
||||
STRAIGHT,
|
||||
0,
|
||||
zone2zoneClearance,
|
||||
&x, &y );
|
||||
|
@ -987,9 +985,9 @@ bool DRC::doEdgeZoneDrc( ZONE_CONTAINER* aArea, int aCornerIndex )
|
|||
}
|
||||
|
||||
int x, y; // variables containing the intersecting point coordinates
|
||||
int d = GetClearanceBetweenSegments( bx1, by1, bx2, by2, STRAIGHT,
|
||||
int d = GetClearanceBetweenSegments( bx1, by1, bx2, by2,
|
||||
0,
|
||||
ax1, ay1, ax2, ay2, STRAIGHT,
|
||||
ax1, ay1, ax2, ay2,
|
||||
0,
|
||||
zone_clearance,
|
||||
&x, &y );
|
||||
|
|
|
@ -1112,7 +1112,6 @@ void CPolyLine::Hatch()
|
|||
m_CornersList[ic].x, m_CornersList[ic].y,
|
||||
m_CornersList[i_start_contour].x,
|
||||
m_CornersList[i_start_contour].y,
|
||||
STRAIGHT,
|
||||
&x, &y, &x2, &y2 );
|
||||
i_start_contour = ic + 1;
|
||||
}
|
||||
|
@ -1121,7 +1120,6 @@ void CPolyLine::Hatch()
|
|||
ok = FindLineSegmentIntersection( a, slope,
|
||||
m_CornersList[ic].x, m_CornersList[ic].y,
|
||||
m_CornersList[ic + 1].x, m_CornersList[ic + 1].y,
|
||||
STRAIGHT,
|
||||
&x, &y, &x2, &y2 );
|
||||
}
|
||||
|
||||
|
@ -1387,9 +1385,9 @@ int CPolyLine::Distance( wxPoint aStart, wxPoint aEnd, int aWidth )
|
|||
by2 = GetY( ic2 + 1 );
|
||||
}
|
||||
|
||||
int d = GetClearanceBetweenSegments( bx1, by1, bx2, by2, STRAIGHT, 0,
|
||||
int d = GetClearanceBetweenSegments( bx1, by1, bx2, by2, 0,
|
||||
aStart.x, aStart.y, aEnd.x, aEnd.y,
|
||||
STRAIGHT, aWidth,
|
||||
aWidth,
|
||||
1, // min clearance, should be > 0
|
||||
NULL, NULL );
|
||||
|
||||
|
@ -1689,9 +1687,7 @@ bool CPolyLine::IsPolygonSelfIntersecting()
|
|||
int x2f = GetX( is2_next );
|
||||
int y2f = GetY( is2_next );
|
||||
int ret = FindSegmentIntersections( x1i, y1i, x1f, y1f,
|
||||
STRAIGHT,
|
||||
x2i, y2i, x2f, y2f,
|
||||
STRAIGHT );
|
||||
x2i, y2i, x2f, y2f );
|
||||
if( ret )
|
||||
{
|
||||
// intersection between non-adjacent sides
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -10,12 +10,23 @@
|
|||
*/
|
||||
bool TestLineHit( int xi, int yi, int xf, int yf, int x, int y, double dist );
|
||||
|
||||
int FindLineSegmentIntersection( double a, double b, int xi, int yi, int xf, int yf, int style,
|
||||
/* Function FindLineSegmentIntersection
|
||||
* find intersection between line y = a + bx and line segment (xi,yi) to (xf,yf)
|
||||
* if b > DBL_MAX/10, assume vertical line at x = a
|
||||
* return false if no intersection or true if intersect
|
||||
* return coords of intersections in *x1, *y1, *x2, *y2
|
||||
* if no intersection, returns min distance in dist
|
||||
*/
|
||||
bool FindLineSegmentIntersection( double a, double b, int xi, int yi, int xf, int yf,
|
||||
double * x1, double * y1, double * x2, double * y2, double * dist=NULL );
|
||||
|
||||
int FindSegmentIntersections( int xi, int yi, int xf, int yf, int style,
|
||||
int xi2, int yi2, int xf2, int yf2, int style2,
|
||||
double x[]=NULL, double y[]=NULL );
|
||||
/* Function FindSegmentIntersections
|
||||
* find intersections between line segment (xi,yi) to (xf,yf)
|
||||
* and line segment (xi2,yi2) to (xf2,yf2)
|
||||
* returns true if intersection found
|
||||
*/
|
||||
bool FindSegmentIntersections( int xi, int yi, int xf, int yf,
|
||||
int xi2, int yi2, int xf2, int yf2 );
|
||||
|
||||
/**
|
||||
* Function TestForIntersectionOfStraightLineSegments
|
||||
|
@ -34,8 +45,13 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y
|
|||
int x2i, int y2i, int x2f, int y2f,
|
||||
int * x=NULL, int * y=NULL, double * dist=NULL );
|
||||
|
||||
int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int style1, int w1,
|
||||
int x2i, int y2i, int x2f, int y2f, int style2, int w2,
|
||||
/* Function GetClearanceBetweenSegments
|
||||
* Get clearance between 2 segments
|
||||
* Returns coordinates of the closest point between these 2 segments in x, y
|
||||
* If clearance > max_cl, just returns max_cl+1 and doesn't return x,y
|
||||
*/
|
||||
int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int w1,
|
||||
int x2i, int y2i, int x2f, int y2f, int w2,
|
||||
int max_cl, int * x, int * y );
|
||||
|
||||
/**
|
||||
|
@ -47,6 +63,11 @@ int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int style1,
|
|||
*/
|
||||
double GetPointToLineSegmentDistance( int x, int y, int xi, int yi, int xf, int yf );
|
||||
|
||||
/* Function GetPointToLineDistance
|
||||
* Get min. distance from (x,y) to line y = a + bx
|
||||
* if b > DBL_MAX/10, assume vertical line at x = a
|
||||
* returns closest point on line in xpp, ypp
|
||||
*/
|
||||
double GetPointToLineDistance( double a, double b, int x, int y, double * xp=NULL, double * yp=NULL );
|
||||
|
||||
double Distance( double x1, double y1, double x2, double y2 );
|
||||
|
|
Loading…
Reference in New Issue