Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <cstdio>
- #include <vector>
- #include <cmath>
- using namespace std;
- const long double inf = 2e18;
- struct point {
- long double x, y;
- long double len() {
- return sqrt(x * x + y * y);
- }
- void build(long double a, long double b) {
- x = a;
- y = b;
- }
- };
- struct line {
- long double a, b, c, k, m;
- long double getY(long double x) {
- if (b == 0) {
- return inf;
- }
- return -(c + a * x) / b;
- }
- long double getX(long double y) {
- if (a == 0) {
- return inf;
- }
- return -(c + b * y) / a;
- }
- void buildPoints(point x, point y) {
- a = x.y - y.y;
- b = y.x - x.x;
- c = x.x * y.y - y.x * x.y;
- if (b == 0) {
- m = inf + x.x;
- k = inf;
- } else {
- m = -c / b;
- k = -a / b;
- }
- }
- void build(long double A, long double B, long double C) {
- a = A;
- b = B;
- c = C;
- if (b == 0) {
- m = inf;
- k = inf;
- } else {
- m = -c / b;
- k = -a / b;
- }
- }
- };
- long double operator*(point a, point b) {
- return a.x * b.x + a.y * b.y;
- }
- long double operator^(point a, point b) {
- return a.x * b.y - a.y * b.x;
- }
- point operator-(point a, point b) {
- point res;
- res.x = a.x - b.x;
- res.y = a.y - b.y;
- return res;
- }
- point operator+(point a, point b) {
- point res;
- res.x = a.x + b.x;
- res.y = a.y + b.y;
- return res;
- }
- point operator*(long double k, point a) {
- point res;
- res.build(a.x * k, a.y * k);
- return res;
- }
- long double distance(line l, point p) {
- return abs(l.a * p.x + l.b * p.y + l.c) / sqrt(l.a * l.a + l.b * l.b);
- }
- int main() {
- line ans;
- point x, y, z, p;
- long double a, b, ratio;
- scanf("%Lf %Lf %Lf %Lf %Lf %Lf", &x.x, &x.y, &y.x, &y.y, &z.x, &z.y);
- a = (x - y).len();
- b = (x - z).len();
- ratio = a / b;
- p = (1 / (ratio + 1)) * (y - z) + z;
- // printf("%Lf %Lf\n", p.x, p.y);
- ans.buildPoints(x, p);
- printf("%Lf %Lf %Lf", ans.a, ans.b, ans.c);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement