Index: trunk/src_plugins/rubberband_orig/fgeometry.c =================================================================== --- trunk/src_plugins/rubberband_orig/fgeometry.c (revision 7511) +++ trunk/src_plugins/rubberband_orig/fgeometry.c (revision 7512) @@ -5,18 +5,18 @@ #define MIN_COMPONENT 0.000001 -int fvector_is_null (fvector v) +int pcb_fvector_is_null (pcb_fvector_t v) { return fabs(v.x) < MIN_COMPONENT && fabs(v.y) < MIN_COMPONENT; } -double fvector_dot (fvector v1, fvector v2) +double pcb_fvector_dot (pcb_fvector_t v1, pcb_fvector_t v2) { return v1.x * v2.x + v1.y * v2.y; } -void fvector_normalize (fvector *v) +void pcb_fvector_normalize (pcb_fvector_t *v) { double module = sqrt(v->x * v->x + v->y * v->y); @@ -24,14 +24,14 @@ v->y /= module; } -int fline_is_valid(fline l) +int pcb_fline_is_valid(pcb_fline_t l) { - return !fvector_is_null(l.direction); + return !pcb_fvector_is_null(l.direction); } -fline fline_create(pcb_any_line_t *line) +pcb_fline_t pcb_fline_create(pcb_any_line_t *line) { - fline ret; + pcb_fline_t ret; ret.point.x = line->Point1.X; ret.point.y = line->Point1.Y; @@ -38,16 +38,16 @@ ret.direction.x = line->Point2.X - line->Point1.X; ret.direction.y = line->Point2.Y - line->Point1.Y; - if (!fvector_is_null (ret.direction)) - fvector_normalize( &ret.direction ); + if (!pcb_fvector_is_null (ret.direction)) + pcb_fvector_normalize( &ret.direction ); return ret; } -fline fline_create_from_points(struct pcb_point_s *base_point, struct pcb_point_s *other_point) +pcb_fline_t pcb_fline_create_from_points(struct pcb_point_s *base_point, struct pcb_point_s *other_point) { - fline ret; + pcb_fline_t ret; ret.point.x = base_point->X; ret.point.y = base_point->Y; @@ -54,20 +54,20 @@ ret.direction.x = other_point->X - base_point->X; ret.direction.y = other_point->Y - base_point->Y; - if (!fvector_is_null (ret.direction)) - fvector_normalize( &ret.direction ); + if (!pcb_fvector_is_null (ret.direction)) + pcb_fvector_normalize( &ret.direction ); return ret; } -fvector fline_intersection(fline l1, fline l2) +pcb_fvector_t pcb_fline_intersection(pcb_fline_t l1, pcb_fline_t l2) { - fvector ret; + pcb_fvector_t ret; ret.x = 0; ret.y = 0; - double lines_dot = fvector_dot (l1.direction, l2.direction); + double lines_dot = pcb_fvector_dot (l1.direction, l2.direction); if (fabs(lines_dot) > 0.990 ) { /* Consider them parallel. Return null point (vector) */ Index: trunk/src_plugins/rubberband_orig/fgeometry.h =================================================================== --- trunk/src_plugins/rubberband_orig/fgeometry.h (revision 7511) +++ trunk/src_plugins/rubberband_orig/fgeometry.h (revision 7512) @@ -4,11 +4,11 @@ #include "obj_common.h" -typedef struct +typedef struct pcb_fvector_s { double x; double y; -} fvector; +} pcb_fvector_t; /* flines should be created through fline_create* functions. @@ -15,27 +15,27 @@ * Alternatively, they can be created manually as long as * direction is normalized */ -typedef struct +typedef struct pcb_fline_s { - fvector point; - fvector direction; -} fline; + pcb_fvector_t point; + pcb_fvector_t direction; +} pcb_fline_t; -int fvector_is_null(fvector v); +int pcb_fvector_is_null(pcb_fvector_t v); /* Any vector given to the following functions has to be non-null */ -double fvector_dot (fvector v1, fvector v2); -void fvector_normalize (fvector *v); +double pcb_fvector_dot(pcb_fvector_t v1, pcb_fvector_t v2); +void pcb_fvector_normalize(pcb_fvector_t *v); -fline fline_create(pcb_any_line_t *line); -fline fline_create_from_points(struct pcb_point_s *base_point, struct pcb_point_s *other_point); +pcb_fline_t pcb_fline_create(pcb_any_line_t *line); +pcb_fline_t pcb_fline_create_from_points(struct pcb_point_s *base_point, struct pcb_point_s *other_point); -int fline_is_valid(fline l); +int pcb_fline_is_valid(pcb_fline_t l); /* l1.direction and l2.direction are expected to be normalized */ -fvector fline_intersection(fline l1, fline l2); +pcb_fvector_t pcb_fline_intersection(pcb_fline_t l1, pcb_fline_t l2); #endif Index: trunk/src_plugins/rubberband_orig/rubberband.c =================================================================== --- trunk/src_plugins/rubberband_orig/rubberband.c (revision 7511) +++ trunk/src_plugins/rubberband_orig/rubberband.c (revision 7512) @@ -914,27 +914,27 @@ pcb_line_t *rub2 = rbnd->Rubberband[1].Line; /* Create float point-vector representations of the lines */ - fline fmain, frub1, frub2; - fmain = fline_create_from_points (&line->Point1, &line->Point2); + pcb_fline_t fmain, frub1, frub2; + fmain = pcb_fline_create_from_points(&line->Point1, &line->Point2); if (rbnd->Rubberband[0].MovedPoint == &rub1->Point1) - frub1 = fline_create_from_points (&rub1->Point1, &rub1->Point2); + frub1 = pcb_fline_create_from_points(&rub1->Point1, &rub1->Point2); else - frub1 = fline_create_from_points (&rub1->Point2, &rub1->Point1); + frub1 = pcb_fline_create_from_points(&rub1->Point2, &rub1->Point1); if (rbnd->Rubberband[1].MovedPoint == &rub2->Point1) - frub2 = fline_create_from_points (&rub2->Point1, &rub2->Point2); + frub2 = pcb_fline_create_from_points(&rub2->Point1, &rub2->Point2); else - frub2 = fline_create_from_points (&rub2->Point2, &rub2->Point1); + frub2 = pcb_fline_create_from_points(&rub2->Point2, &rub2->Point1); /* If they are valid (non-null directions) we carry on */ - if (fline_is_valid(fmain) && fline_is_valid(frub1) && fline_is_valid(frub2)) { - fvector fmove; + if (pcb_fline_is_valid(fmain) && pcb_fline_is_valid(frub1) && pcb_fline_is_valid(frub2)) { + pcb_fvector_t fmove; - fvector fintersection = fline_intersection(frub1, frub2); + pcb_fvector_t fintersection = pcb_fline_intersection(frub1, frub2); - if (!fvector_is_null(fintersection)) { + if (!pcb_fvector_is_null(fintersection)) { /* Movement direction defined as from mid line to intersection point */ - fvector fmid; + pcb_fvector_t fmid; fmid.x = ((double)line->Point2.X + line->Point1.X) / 2.0; fmid.y = ((double)line->Point2.Y + line->Point1.Y) / 2.0; fmove.x = fintersection.x - fmid.x; @@ -946,19 +946,19 @@ fmove.y = frub1.direction.y; } - if (!fvector_is_null(fmove)) { - fvector_normalize(&fmove); + if (!pcb_fvector_is_null(fmove)) { + pcb_fvector_normalize(&fmove); /* Cursor delta vector */ - fvector fcursor_delta; + pcb_fvector_t fcursor_delta; fcursor_delta.x = pcb_crosshair->X - pcb_marked->X; fcursor_delta.y = pcb_crosshair->Y - pcb_marked->Y; /* Cursor delta projection on movement direction */ - double amount_moved = fvector_dot(fmove, fcursor_delta); + double amount_moved = pcb_fvector_dot(fmove, fcursor_delta); /* Scale fmove by calculated amount */ - fvector fmove_total; + pcb_fvector_t fmove_total; fmove_total.x = fmove.x * amount_moved; fmove_total.y = fmove.y * amount_moved; @@ -969,19 +969,19 @@ /* Move rubberband: fmove_totalˇnormal = fmove_rubberbandˇnormal * where normal is the moving line normal */ - fvector fnormal; + pcb_fvector_t fnormal; fnormal.x = fmain.direction.y; fnormal.y = -fmain.direction.x; - if (fvector_dot(fnormal, fmove) < 0) { + if (pcb_fvector_dot(fnormal, fmove) < 0) { fnormal.x = -fnormal.x; fnormal.y = -fnormal.y; } - double rub1_move = amount_moved * fvector_dot(fmove, fnormal) / fvector_dot(frub1.direction, fnormal); + double rub1_move = amount_moved * pcb_fvector_dot(fmove, fnormal) / pcb_fvector_dot(frub1.direction, fnormal); rbnd->Rubberband[0].DX = rub1_move*frub1.direction.x; rbnd->Rubberband[0].DY = rub1_move*frub1.direction.y; rbnd->Rubberband[0].delta_is_valid = 1; - double rub2_move = amount_moved * fvector_dot(fmove, fnormal) / fvector_dot(frub2.direction, fnormal); + double rub2_move = amount_moved * pcb_fvector_dot(fmove, fnormal) / pcb_fvector_dot(frub2.direction, fnormal); rbnd->Rubberband[1].DX = rub2_move*frub2.direction.x; rbnd->Rubberband[1].DY = rub2_move*frub2.direction.y; rbnd->Rubberband[1].delta_is_valid = 1;