Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- struct Point {
- double x, y;
- Point(double x0 = 0, double y0 = 0)
- {
- x = x0;
- y = y0;
- }
- };
- istream & operator >> (istream & in, Point & P) {
- in >> P.x >> P.y;
- return in;
- }
- ostream & operator << (ostream & out, Point & P) {
- out << P.x << " " << P.y;
- return out;
- }
- struct Vector {
- double x, y;
- Vector(double x0, double y0) {
- x = x0;
- y = y0;
- }
- Vector(Point A = Point(0, 0), Point B = Point(0, 0)) {
- x = B.x - A.x;
- y = B.y - A.y;
- }
- };
- double getDist(Point A, double a, double b, double c) {
- return fabs((a * A.x + b * A.y + c)) / hypot(a, b);
- }
- double* getBisectorEquation(Point B, Point A, Point C) {
- // bac bisector
- Vector AB = Vector(A, B);
- Vector AC = Vector(A, C);
- double* k = new double[3];
- k[0] = AB.y / hypot(AB.x, AB.y) + AC.y / hypot(AC.x, AC.y);
- k[1] = AB.x / hypot(AB.x, AB.y) + AC.x / hypot(AC.x, AC.y);
- k[2] = k[1] * A.y - k[0] * A.x;
- k[1] = -k[1];
- return k;
- }
- int main() {
- Point O;
- double r, a, b, c;
- cin >> O >> r >> a >> b >> c;
- cout << fixed << setprecision(10);
- double dist = (a * O.x + b * O.y + c) / hypot(a, b);
- if (fabs(dist) > r)
- cout << 0;
- else
- if (fabs(dist) == r) {
- cout << 1 << endl;
- Point M = Point(-a * dist / hypot(a, b) + O.x, O.y - b * dist / hypot(a, b));
- cout << M;
- }
- else {
- cout << 2 << endl;
- Point M = Point(-a * dist / hypot(a, b) + O.x, O.y - b * dist / hypot(a, b));
- if (M.x == O.x && M.y == O.y) {
- Vector norm = Vector(a, b);
- double a1 = b, b1 = -a;
- double c1 = - b * O.x + a * O.y;
- M = Point(-a1 * c1 / (a1 * a1 + b1 * b1), -b1 * c1 / (a1 * a1 + b1 * b1));
- if (a * M.x + b * M.y + c == 0) {
- M = Point(-a1 * c1 / (a1 * a1 + b1 * b1) - b1, a1 - b1 * c1 / (a1 * a1 + b1 * b1));
- }
- }
- Vector OM = Vector(O, M);
- Vector OH = Vector(OM.x * r / hypot(OM.x, OM.y), OM.y * r / hypot(OM.x, OM.y));
- Point H = Point(OH.x + O.x, OH.y + O.y);
- double cosAlpha = abs(dist / r);
- double sinAlpha = sqrt(1 - cosAlpha * cosAlpha);
- Point K1 = Point(O.x + (H.x - O.x) * cosAlpha - sinAlpha * (H.y - O.y),
- O.y + (H.x - O.x) * sinAlpha + cosAlpha * (H.y - O.y));
- sinAlpha = -sinAlpha;
- Point K2 = Point(O.x + (H.x - O.x) * cosAlpha - sinAlpha * (H.y - O.y),
- O.y + (H.x - O.x) * sinAlpha + cosAlpha * (H.y - O.y));
- cout << K1 << endl << K2;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement