lib_arc.cpp File Reference
`#include <fctsys.h>`
`#include <gr_basic.h>`
`#include <macros.h>`
`#include <sch_draw_panel.h>`
`#include <plotter.h>`
`#include <trigo.h>`
`#include <base_units.h>`
`#include <msgpanel.h>`
`#include <bitmaps.h>`
`#include <general.h>`
`#include <lib_arc.h>`
`#include <transform.h>`

Go to the source code of this file.

## Functions

static wxPoint twoPointVector (const wxPoint &startPoint, const wxPoint &endPoint)

static wxPoint calcCenter (const wxPoint &A, const wxPoint &B, const wxPoint &C)
Given three points A B C, compute the circumcenter of the resulting triangle reference: http://en.wikipedia.org/wiki/Circumscribed_circle Coordinates of circumcenter in Cartesian coordinates. More...

## Function Documentation

 static wxPoint calcCenter ( const wxPoint & A, const wxPoint & B, const wxPoint & C )
static

Given three points A B C, compute the circumcenter of the resulting triangle reference: http://en.wikipedia.org/wiki/Circumscribed_circle Coordinates of circumcenter in Cartesian coordinates.

Definition at line 53 of file lib_arc.cpp.

References D, wxPoint::x, and wxPoint::y.

Referenced by LIB_ARC::CalcEdit().

54 {
55  double circumCenterX, circumCenterY;
56  double Ax = (double) A.x;
57  double Ay = (double) A.y;
58  double Bx = (double) B.x;
59  double By = (double) B.y;
60  double Cx = (double) C.x;
61  double Cy = (double) C.y;
62
63  wxPoint circumCenter;
64
65  double D = 2.0 * ( Ax * ( By - Cy ) + Bx * ( Cy - Ay ) + Cx * ( Ay - By ) );
66
67  // prevent division / 0
68  if( fabs( D ) < 1e-7 )
69  D = 1e-7;
70
71  circumCenterX = ( (Ay * Ay + Ax * Ax) * (By - Cy) +
72  (By * By + Bx * Bx) * (Cy - Ay) +
73  (Cy * Cy + Cx * Cx) * (Ay - By) ) / D;
74
75  circumCenterY = ( (Ay * Ay + Ax * Ax) * (Cx - Bx) +
76  (By * By + Bx * Bx) * (Ax - Cx) +
77  (Cy * Cy + Cx * Cx) * (Bx - Ax) ) / D;
78
79  circumCenter.x = (int) circumCenterX;
80  circumCenter.y = (int) circumCenterY;
81
82  return circumCenter;
83 }
#define D(x)
Definition: ptree.cpp:41
 static wxPoint twoPointVector ( const wxPoint & startPoint, const wxPoint & endPoint )
inlinestatic

Definition at line 44 of file lib_arc.cpp.

Referenced by LIB_ARC::BeginEdit(), LIB_ARC::CalcEdit(), LIB_ARC::CalcRadiusAngles(), and LIB_ARC::HitTest().

45 {
46  return endPoint - startPoint;
47 }