#include #include #include "R2Graph.h" using namespace std; void inCircle( const R2Point& a, const R2Point& b, const R2Point& c, R2Point& center, double& radius ); int main() { while (true) { R2Point a, b, c; cout << "Enter vertices of triangle:" << endl; cin >> a >> b >> c; if (!cin) break; R2Point center; double radius; inCircle(a, b, c, center, radius); cout << "Center of inscribed circle: " << center << endl; cout << "Radius: " << radius << endl; } return 0; } void inCircle( const R2Point& a, const R2Point& b, const R2Point& c, R2Point& center, double& radius ) { R2Vector ab = b - a; ab.normalize(); R2Vector ac = c - a; ac.normalize(); R2Vector bisa = ab + ac; R2Vector ba = a - b; ba.normalize(); R2Vector bc = c - b; bc.normalize(); R2Vector bisb = ba + bc; intersectStraightLines( a, bisa, b, bisb, center ); R2Vector n = ab.normal(); n.normalize(); radius = n*(center - a); }