Commit ef39c5f3 authored by jean-pierre charras's avatar jean-pierre charras

PolyLine and math_for_graphics code cleanup: remove arc support in CPolyLine class:

This is an obscure legacy code from FreePCB, never used, never tested, never maintained.
parents 474128a4 90a6daa7
...@@ -1041,7 +1041,7 @@ public: ...@@ -1041,7 +1041,7 @@ public:
* @param aLayer = the layer of area * @param aLayer = the layer of area
* @param aStartPointPosition = position of the first point of the polygon outline of this area * @param aStartPointPosition = position of the first point of the polygon outline of this area
* @param aHatch = hatch option * @param aHatch = hatch option
* @return pointer to the new area * @return a reference to the new area
*/ */
ZONE_CONTAINER* AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, ZONE_CONTAINER* AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode,
int aLayer, wxPoint aStartPointPosition, int aHatch ); int aLayer, wxPoint aStartPointPosition, int aHatch );
...@@ -1054,58 +1054,30 @@ public: ...@@ -1054,58 +1054,30 @@ public:
ZONE_CONTAINER* InsertArea( int netcode, int iarea, int layer, int x, int y, int hatch ); ZONE_CONTAINER* InsertArea( int netcode, int iarea, int layer, int x, int y, int hatch );
/** /**
* Function TestAreaPolygon * Function NormalizeAreaPolygon
* Test an area for self-intersection. * Process an area that has been modified, by normalizing its polygon against itself.
* * i.e. convert a self-intersecting polygon to one (or more) non self-intersecting polygon(s)
* @param CurrArea = copper area to test
* @return :
* -1 if arcs intersect other sides
* 0 if no intersecting sides
* 1 if intersecting sides, but no intersecting arcs
* Also sets utility2 flag of area with return value
*/
int TestAreaPolygon( ZONE_CONTAINER* CurrArea );
/**
* Function ClipAreaPolygon
* Process an area that has been modified, by clipping its polygon against itself.
* This may change the number and order of copper areas in the net. * This may change the number and order of copper areas in the net.
* @param aNewZonesList = a PICKED_ITEMS_LIST * where to store new areas pickers (useful * @param aNewZonesList = a PICKED_ITEMS_LIST * where to store new created areas pickers
* in undo commands) can be NULL
* @param aCurrArea = the zone to process * @param aCurrArea = the zone to process
* @param bMessageBoxInt == true, shows message when clipping occurs. * @return true if changes are made
* @param bMessageBoxArc == true, shows message when clipping can't be done due to arcs.
* @param bRetainArcs = true to handle arcs (not really used in KiCad)
* @return :
* -1 if arcs intersect other sides, so polygon can't be clipped
* 0 if no intersecting sides
* 1 if intersecting sides
* Also sets areas->utility1 flags if areas are modified * Also sets areas->utility1 flags if areas are modified
*/ */
int ClipAreaPolygon( PICKED_ITEMS_LIST* aNewZonesList, bool NormalizeAreaPolygon( PICKED_ITEMS_LIST * aNewZonesList,
ZONE_CONTAINER* aCurrArea, ZONE_CONTAINER* aCurrArea );
bool bMessageBoxArc,
bool bMessageBoxInt,
bool bRetainArcs = true );
/** /**
* Process an area that has been modified, by clipping its polygon against * Function OnAreaPolygonModified
* itself and the polygons for any other areas on the same net. * Process an area that has been modified, by normalizing its polygon
* and merging the intersecting polygons for any other areas on the same net.
* This may change the number and order of copper areas in the net. * This may change the number and order of copper areas in the net.
* @param aModifiedZonesList = a PICKED_ITEMS_LIST * where to store deleted or added areas * @param aModifiedZonesList = a PICKED_ITEMS_LIST * where to store deleted or added areas
* (useful in undo commands. Can be NULL * (useful in undo commands can be NULL
* @param modified_area = area to test * @param modified_area = area to test
* @param bMessageBoxInt : if true, shows message boxes when clipping occurs. * @return true if some areas modified
* @param bMessageBoxArc if true, shows message when clipping can't be done due to arcs. */
* @return : bool OnAreaPolygonModified( PICKED_ITEMS_LIST* aModifiedZonesList,
* -1 if arcs intersect other sides, so polygon can't be clipped ZONE_CONTAINER* modified_area );
* 0 if no intersecting sides
* 1 if intersecting sides, polygon clipped
*/
int AreaPolygonModified( PICKED_ITEMS_LIST* aModifiedZonesList,
ZONE_CONTAINER* modified_area,
bool bMessageBoxArc,
bool bMessageBoxInt );
/** /**
* Function CombineAllAreasInNet * Function CombineAllAreasInNet
...@@ -1113,15 +1085,13 @@ public: ...@@ -1113,15 +1085,13 @@ public:
* @param aDeletedList = a PICKED_ITEMS_LIST * where to store deleted areas (useful * @param aDeletedList = a PICKED_ITEMS_LIST * where to store deleted areas (useful
* in undo commands can be NULL * in undo commands can be NULL
* @param aNetCode = net to consider * @param aNetCode = net to consider
* @param bMessageBox : if true display warning message box * @param aUseUtility : if true, don't check areas if both utility flags are 0
* @param bUseUtility : if true, don't check areas if both utility flags are 0
* Sets utility flag = 1 for any areas modified * Sets utility flag = 1 for any areas modified
* If an area has self-intersecting arcs, doesn't try to combine it * @return true if some areas modified
*/ */
int CombineAllAreasInNet( PICKED_ITEMS_LIST* aDeletedList, bool CombineAllAreasInNet( PICKED_ITEMS_LIST* aDeletedList,
int aNetCode, int aNetCode,
bool bMessageBox, bool aUseUtility );
bool bUseUtility );
/** /**
* Function RemoveArea * Function RemoveArea
...@@ -1154,19 +1124,17 @@ public: ...@@ -1154,19 +1124,17 @@ public:
/** /**
* Function CombineAreas * Function CombineAreas
* If possible, combine 2 copper areas * If possible, combine 2 copper areas
* @param aDeletedList = a PICKED_ITEMS_LIST * where to store deleted areas (useful * @param aDeletedList = a PICKED_ITEMS_LIST * where to store deleted areas
* in undo commands can be NULL * (useful for undo).
* @param area_ref = the main area (zone) * @param area_ref = the main area (zone)
* @param area_to_combine = the zone that can be merged with area_ref * @param area_to_combine = the zone that can be merged with area_ref
* area_ref must be BEFORE area_to_combine * area_ref must be BEFORE area_to_combine
* area_to_combine will be deleted, if areas are combined * area_to_combine will be deleted, if areas are combined
* @return : 0 if no intersection * @return : true if area_to_combine is combined with area_ref (and therefore be deleted)
* 1 if intersection
* 2 if arcs intersect
*/ */
int CombineAreas( PICKED_ITEMS_LIST* aDeletedList, bool CombineAreas( PICKED_ITEMS_LIST* aDeletedList,
ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_ref,
ZONE_CONTAINER* area_to_combine ); ZONE_CONTAINER* area_to_combine );
/** /**
* Function Test_Drc_Areas_Outlines_To_Areas_Outlines * Function Test_Drc_Areas_Outlines_To_Areas_Outlines
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <class_board.h> #include <class_board.h>
#include <class_module.h> #include <class_module.h>
#include <polygon_test_point_inside.h>
int D_PAD::m_PadSketchModePenSize = 0; // Pen size used to draw pads in sketch mode int D_PAD::m_PadSketchModePenSize = 0; // Pen size used to draw pads in sketch mode
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include <pcbnew.h> #include <pcbnew.h>
#include <zones.h> #include <zones.h>
#include <math_for_graphics.h> #include <math_for_graphics.h>
#include <polygon_test_point_inside.h>
ZONE_CONTAINER::ZONE_CONTAINER( BOARD* aBoard ) : ZONE_CONTAINER::ZONE_CONTAINER( BOARD* aBoard ) :
...@@ -65,7 +66,6 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* aBoard ) : ...@@ -65,7 +66,6 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* aBoard ) :
SetDoNotAllowTracks( true ); // has meaning only if m_isKeepout == true SetDoNotAllowTracks( true ); // has meaning only if m_isKeepout == true
m_cornerRadius = 0; m_cornerRadius = 0;
utility = 0; // flags used in polygon calculations utility = 0; // flags used in polygon calculations
utility2 = 0; // flags used in polygon calculations
m_Poly = new CPolyLine(); // Outlines m_Poly = new CPolyLine(); // Outlines
aBoard->GetZoneSettings().ExportSetting( *this ); aBoard->GetZoneSettings().ExportSetting( *this );
} }
...@@ -102,7 +102,6 @@ ZONE_CONTAINER::ZONE_CONTAINER( const ZONE_CONTAINER& aZone ) : ...@@ -102,7 +102,6 @@ ZONE_CONTAINER::ZONE_CONTAINER( const ZONE_CONTAINER& aZone ) :
utility = aZone.utility; utility = aZone.utility;
utility2 = aZone.utility;
} }
......
...@@ -573,7 +573,7 @@ public: ...@@ -573,7 +573,7 @@ public:
// thickness of the copper bridge in thermal reliefs // thickness of the copper bridge in thermal reliefs
int m_ThermalReliefCopperBridge; int m_ThermalReliefCopperBridge;
int utility, utility2; // flags used in polygon calculations int utility; // flags used in polygon calculations
// true when a zone was filled, false after deleting the filled areas // true when a zone was filled, false after deleting the filled areas
bool m_IsFilled; bool m_IsFilled;
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <class_zone.h> #include <class_zone.h>
#include <class_marker_pcb.h> #include <class_marker_pcb.h>
#include <math_for_graphics.h> #include <math_for_graphics.h>
#include <polygon_test_point_inside.h>
/* compare 2 trapezoids (can be rectangle) and return true if distance > aDist /* compare 2 trapezoids (can be rectangle) and return true if distance > aDist
......
...@@ -44,8 +44,6 @@ ...@@ -44,8 +44,6 @@
#include <zones_functions_for_undo_redo.h> #include <zones_functions_for_undo_redo.h>
#include <drc_stuff.h> #include <drc_stuff.h>
bool s_Verbose = false; // false if zone outline diags must not be shown
// Outline creation: // Outline creation:
static void Abort_Zone_Create_Outline( EDA_DRAW_PANEL* Panel, wxDC* DC ); static void Abort_Zone_Create_Outline( EDA_DRAW_PANEL* Panel, wxDC* DC );
static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC, static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
...@@ -141,7 +139,7 @@ void PCB_EDIT_FRAME::duplicateZone( wxDC* aDC, ZONE_CONTAINER* aZone ) ...@@ -141,7 +139,7 @@ void PCB_EDIT_FRAME::duplicateZone( wxDC* aDC, ZONE_CONTAINER* aZone )
GetScreen()->SetCurItem( NULL ); // This outline may be deleted when merging outlines GetScreen()->SetCurItem( NULL ); // This outline may be deleted when merging outlines
// Combine zones if possible // Combine zones if possible
GetBoard()->AreaPolygonModified( &_AuxiliaryList, newZone, true, s_Verbose ); GetBoard()->OnAreaPolygonModified( &_AuxiliaryList, newZone );
// Redraw zones // Redraw zones
GetBoard()->RedrawAreasOutlines( m_canvas, aDC, GR_OR, newZone->GetLayer() ); GetBoard()->RedrawAreasOutlines( m_canvas, aDC, GR_OR, newZone->GetLayer() );
...@@ -334,7 +332,7 @@ void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER* ...@@ -334,7 +332,7 @@ void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER*
// Combine zones if possible // Combine zones if possible
wxBusyCursor dummy; wxBusyCursor dummy;
GetBoard()->AreaPolygonModified( &_AuxiliaryList, aZone, true, s_Verbose ); GetBoard()->OnAreaPolygonModified( &_AuxiliaryList, aZone );
m_canvas->Refresh(); m_canvas->Refresh();
...@@ -389,7 +387,7 @@ void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* aZone ) ...@@ -389,7 +387,7 @@ void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* aZone )
aZone->m_Poly->DeleteCorner( aZone->m_CornerSelection ); aZone->m_Poly->DeleteCorner( aZone->m_CornerSelection );
// modify zones outlines according to the new aZone shape // modify zones outlines according to the new aZone shape
GetBoard()->AreaPolygonModified( &_AuxiliaryList, aZone, true, s_Verbose ); GetBoard()->OnAreaPolygonModified( &_AuxiliaryList, aZone );
if( DC ) if( DC )
{ {
...@@ -768,7 +766,7 @@ bool PCB_EDIT_FRAME::End_Zone( wxDC* DC ) ...@@ -768,7 +766,7 @@ bool PCB_EDIT_FRAME::End_Zone( wxDC* DC )
GetScreen()->SetCurItem( NULL ); // This outline can be deleted when merging outlines GetScreen()->SetCurItem( NULL ); // This outline can be deleted when merging outlines
// Combine zones if possible : // Combine zones if possible :
GetBoard()->AreaPolygonModified( &_AuxiliaryList, zone, true, s_Verbose ); GetBoard()->OnAreaPolygonModified( &_AuxiliaryList, zone );
// Redraw the real edge zone : // Redraw the real edge zone :
GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, layer ); GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, layer );
...@@ -898,7 +896,7 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* aZone ) ...@@ -898,7 +896,7 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* aZone )
aZone->SetNetName( net->GetNetname() ); aZone->SetNetName( net->GetNetname() );
// Combine zones if possible // Combine zones if possible
GetBoard()->AreaPolygonModified( &_AuxiliaryList, aZone, true, s_Verbose ); GetBoard()->OnAreaPolygonModified( &_AuxiliaryList, aZone );
// Redraw the real new zone outlines // Redraw the real new zone outlines
GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, -1 ); GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, -1 );
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <pcbnew.h> #include <pcbnew.h>
#include <zones.h> #include <zones.h>
#include <polygon_test_point_inside.h>
/** /**
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <algorithm> // sort #include <algorithm> // sort
#include <fctsys.h> #include <fctsys.h>
#include <common.h> #include <common.h>
#include <macros.h> #include <macros.h>
...@@ -40,6 +39,7 @@ ...@@ -40,6 +39,7 @@
#include <pcbnew.h> #include <pcbnew.h>
#include <zones.h> #include <zones.h>
#include <polygon_test_point_inside.h>
static bool CmpZoneSubnetValue( const BOARD_CONNECTED_ITEM* a, const BOARD_CONNECTED_ITEM* b ); static bool CmpZoneSubnetValue( const BOARD_CONNECTED_ITEM* a, const BOARD_CONNECTED_ITEM* b );
void Merge_SubNets_Connected_By_CopperAreas( BOARD* aPcb, int aNetcode ); void Merge_SubNets_Connected_By_CopperAreas( BOARD* aPcb, int aNetcode );
......
This diff is collapsed.
This diff is collapsed.
...@@ -24,13 +24,13 @@ ...@@ -24,13 +24,13 @@
#include <polygons_defs.h> #include <polygons_defs.h>
// inflection modes for DS_LINE and DS_LINE_VERTEX, used in math_for_graphics.cpp // inflection modes for DS_LINE and DS_LINE_VERTEX, used in math_for_graphics.cpp
enum { /*enum {
IM_NONE = 0, IM_NONE = 0,
IM_90_45, IM_90_45,
IM_45_90, IM_45_90,
IM_90 IM_90
}; };
*/
class CRect class CRect
{ {
...@@ -58,6 +58,7 @@ public: ...@@ -58,6 +58,7 @@ public:
} }
}; };
/*
class CArc class CArc
{ {
public: public:
...@@ -67,7 +68,7 @@ public: ...@@ -67,7 +68,7 @@ public:
int n_steps; // number of straight-line segments in gpc_poly int n_steps; // number of straight-line segments in gpc_poly
bool bFound; bool bFound;
}; };
*/
class CPolyPt : public wxPoint class CPolyPt : public wxPoint
{ {
...@@ -98,27 +99,41 @@ public: ...@@ -98,27 +99,41 @@ public:
}; };
#include <polygon_test_point_inside.h>
class CPolyLine class CPolyLine
{ {
public: public:
enum m_SideStyle { STRAIGHT, ARC_CW, ARC_CCW }; // side styles
enum HATCH_STYLE { NO_HATCH, DIAGONAL_FULL, DIAGONAL_EDGE }; // hatch styles enum HATCH_STYLE { NO_HATCH, DIAGONAL_FULL, DIAGONAL_EDGE }; // hatch styles
// constructors/destructor // constructors/destructor
CPolyLine(); CPolyLine();
~CPolyLine(); ~CPolyLine();
// functions for modifying polyline // functions for modifying the CPolyLine contours
/* initialize a contour
* set layer, hatch style, and starting point
*/
void Start( int layer, int x, int y, int hatch ); void Start( int layer, int x, int y, int hatch );
void AppendCorner( int x, int y, int style = STRAIGHT, bool bDraw = false );
void AppendCorner( int x, int y );
void InsertCorner( int ic, int x, int y ); void InsertCorner( int ic, int x, int y );
void DeleteCorner( int ic, bool bDraw = false ); void DeleteCorner( int ic );
void MoveCorner( int ic, int x, int y ); void MoveCorner( int ic, int x, int y );
void CloseLastContour(); void CloseLastContour();
void RemoveContour( int icont ); void RemoveContour( int icont );
/**
* Function IsPolygonSelfIntersecting
* Test a CPolyLine for self-intersection of vertex (all contours).
*
* @return :
* false if no intersecting sides
* true if intersecting sides
* When a CPolyLine is self intersectic, it need to be normalized.
* (converted to non intersecting polygons)
*/
bool IsPolygonSelfIntersecting();
/** /**
* Function Chamfer * Function Chamfer
* returns a chamfered version of a polygon. * returns a chamfered version of a polygon.
...@@ -180,7 +195,6 @@ public: ...@@ -180,7 +195,6 @@ public:
int GetUtility( int ic ) { return m_CornersList[ic].m_utility; }; int GetUtility( int ic ) { return m_CornersList[ic].m_utility; };
void SetUtility( int ic, int utility ) { m_CornersList[ic].m_utility = utility; }; void SetUtility( int ic, int utility ) { m_CornersList[ic].m_utility = utility; };
int GetSideStyle( int is );
int GetHatchPitch() { return m_hatchPitch; } int GetHatchPitch() { return m_hatchPitch; }
static int GetDefaultHatchPitchMils() { return 20; } // default hatch pitch value in mils static int GetDefaultHatchPitchMils() { return 20; } // default hatch pitch value in mils
...@@ -197,7 +211,6 @@ public: ...@@ -197,7 +211,6 @@ public:
void SetX( int ic, int x ); void SetX( int ic, int x );
void SetY( int ic, int y ); void SetY( int ic, int y );
void SetEndContour( int ic, bool end_contour ); void SetEndContour( int ic, bool end_contour );
void SetSideStyle( int is, int style );
void SetHatchStyle( enum HATCH_STYLE style ) void SetHatchStyle( enum HATCH_STYLE style )
{ {
...@@ -206,10 +219,15 @@ public: ...@@ -206,10 +219,15 @@ public:
void SetHatchPitch( int pitch ) { m_hatchPitch = pitch; } void SetHatchPitch( int pitch ) { m_hatchPitch = pitch; }
int RestoreArcs( std::vector<CArc>* arc_array, std::vector<CPolyLine*>* pa = NULL ); /**
* Function NormalizeAreaOutlines
int NormalizeAreaOutlines( std::vector<CPolyLine*>* pa = NULL, * Convert a self-intersecting polygon to one (or more) non self-intersecting polygon(s)
bool bRetainArcs = false ); * @param aNewPolygonList = a std::vector<CPolyLine*> reference where to store new CPolyLine
* needed by the normalization
* @return the polygon count (always >= 1, becuse there is at lesat one polygon)
* There are new polygons only if the polygon count is > 1
*/
int NormalizeAreaOutlines( std::vector<CPolyLine*>* aNewPolygonList );
// KBOOL functions // KBOOL functions
...@@ -224,12 +242,9 @@ public: ...@@ -224,12 +242,9 @@ public:
/** /**
* Function MakeKboolPoly * Function MakeKboolPoly
* fill a kbool engine with a closed polyline contour * fill a kbool engine with a closed polyline contour
* approximates arcs with multiple straight-line segments
* combining intersecting contours if possible
* @param arc_array : return data on arcs in arc_array
* @return error: 0 if Ok, 1 if error * @return error: 0 if Ok, 1 if error
*/ */
int MakeKboolPoly( std::vector<CArc>* arc_array = NULL ); int MakeKboolPoly();
/** /**
* Function NormalizeWithKbool * Function NormalizeWithKbool
...@@ -240,10 +255,10 @@ public: ...@@ -240,10 +255,10 @@ public:
* because copper areas have only one outside contour * because copper areas have only one outside contour
* Therefore, if this results in new CPolyLines, return them as std::vector pa * Therefore, if this results in new CPolyLines, return them as std::vector pa
* @param aExtraPolyList: pointer on a std::vector<CPolyLine*> to store extra CPolyLines * @param aExtraPolyList: pointer on a std::vector<CPolyLine*> to store extra CPolyLines
* @param bRetainArcs == false, try to retain arcs in polys * (when after normalization, there is more than one polygon with holes)
* @return number of external contours, or -1 if error * @return number of contours, or -1 if error
*/ */
int NormalizeWithKbool( std::vector<CPolyLine*>* aExtraPolyList, bool bRetainArcs ); int NormalizeWithKbool( std::vector<CPolyLine*>* aExtraPolyList );
// Bezier Support // Bezier Support
void AppendBezier( int x1, int y1, int x2, int y2, int x3, int y3 ); void AppendBezier( int x1, int y1, int x2, int y2, int x3, int y3 );
...@@ -280,7 +295,6 @@ private: ...@@ -280,7 +295,6 @@ private:
Bool_Engine* m_Kbool_Poly_Engine; // polygons set in kbool engine data Bool_Engine* m_Kbool_Poly_Engine; // polygons set in kbool engine data
public: public:
std::vector <CPolyPt> m_CornersList; // array of points for corners std::vector <CPolyPt> m_CornersList; // array of points for corners
std::vector <int> m_SideStyle; // array of styles for sides
std::vector <CSegment> m_HatchLines; // hatch lines showing the polygon area std::vector <CSegment> m_HatchLines; // hatch lines showing the polygon area
}; };
......
This diff is collapsed.
// math stuff for graphics, from FreePCB // math stuff for graphics, from FreePCB
// math stuff for graphics
bool Quadratic( double a, double b, double c, double *x1, double *x2 );
/** /**
* Function TestLineHit * Function TestLineHit
* test for hit on line segment i.e. a point within a given distance from segment * test for hit on line segment i.e. a point within a given distance from segment
...@@ -14,13 +10,23 @@ bool Quadratic( double a, double b, double c, double *x1, double *x2 ); ...@@ -14,13 +10,23 @@ bool Quadratic( double a, double b, double c, double *x1, double *x2 );
*/ */
bool TestLineHit( int xi, int yi, int xf, int yf, int x, int y, double dist ); 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 ); 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, /* Function FindSegmentIntersections
double x[]=NULL, double y[]=NULL ); * find intersections between line segment (xi,yi) to (xf,yf)
bool FindLineEllipseIntersections( double a, double b, double c, double d, double *x1, double *x2 ); * and line segment (xi2,yi2) to (xf2,yf2)
bool FindVerticalLineEllipseIntersections( double a, double b, double x, double *y1, double *y2 ); * 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 * Function TestForIntersectionOfStraightLineSegments
...@@ -39,8 +45,13 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y ...@@ -39,8 +45,13 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y
int x2i, int y2i, int x2f, int y2f, int x2i, int y2i, int x2f, int y2f,
int * x=NULL, int * y=NULL, double * dist=NULL ); int * x=NULL, int * y=NULL, double * dist=NULL );
int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int style1, int w1, /* Function GetClearanceBetweenSegments
int x2i, int y2i, int x2f, int y2f, int style2, int w2, * 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 ); int max_cl, int * x, int * y );
/** /**
...@@ -52,6 +63,11 @@ int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int style1, ...@@ -52,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 ); 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 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 ); double Distance( double x1, double y1, double x2, double y2 );
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment