Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
2720
#include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() { double x_A, y_A, x_B, y_B, x_C, y_C, A1, B1, C1, A2, B2, C2, A3, B3, C3, a, b, c, r, x0_1, y0_1, x0_2, y0_2, x0_3, y0_3, x0_4, y0_4; scanf("%lf%lf%lf%lf%lf%lf", &x_A, &y_A, &x_B, &y_B, &x_C, &y_C); A1 = y_A - y_B; B1 = x_B - x_A; C1 = (x_A - x_B) * y_A - (y_A - y_B) * x_A; A2 = y_A - y_C; B2 = x_C - x_A; C2 = (x_A - x_C) * y_A - (y_A - y_C) * x_A; A3 = y_B - y_C; B3 = x_C - x_B; C3 = (x_B - x_C) * y_B - (y_B - y_C) * x_B; cout << A1 << " " << B1 << " " << C1 << endl; cout << A2 << " " << B2 << " " << C2 << endl; a = sqrt((x_A - x_B) * (x_A - x_B) + (y_A - y_B) * (y_A - y_B)); b = sqrt((x_A - x_C) * (x_A - x_C) + (y_A - y_C) * (y_A - y_C)); c = sqrt((x_B - x_C) * (x_B - x_C) + (y_B - y_C) * (y_B - y_C)); r = ((a + b + c) / 2 - c) * tan(acos((a * a + b * b - c * c) / (2 * a * b)) / 2); if (A1 == 0) { y0_1 = (r * sqrt(A1 * A1 + B1 * B1) - C1) / B1; if (B2 == 0) x0_1 = (-1 * r * sqrt(A2 * A2 + B2 * B2) - C2) / A2; else x0_1 = (-1 * r * sqrt(A2 * A2 + B2 * B2) - C2 - B2 * y0_1) / A2; } else if (A2 == 0) { y0_1 = (-1 * r * sqrt(A2 * A2 + B2 * B2) - C2) / B2; if (B1 == 0) x0_1 = (r * sqrt(A1 * A1 + B1 * B1) - C1) / A1; else x0_1 = (r * sqrt(A1 * A1 + B1 * B1) - C1 - B1 * y0_1); } else { x0_1 = ((r * sqrt(A1 * A1 + B1 * B1) - C1) * abs(B2) + (-1 * r * sqrt(A2 * A2 + B2 * B2) - C2) * abs(B1)) / (A1 * abs(B2) + A2 * abs(B1)); y0_1 = (r * sqrt(A1 * A1 + B1 * B1) - C1 - A1 * x0_1) / B1; } if (A1 == 0) { y0_2 = (-1 * r * sqrt(A1 * A1 + B1 * B1) - C1) / B1; if (B2 == 0) x0_2 = (r * sqrt(A2 * A2 + B2 * B2) - C2) / A2; else x0_2 = (r * sqrt(A2 * A2 + B2 * B2) - C2 - B2 * y0_2) / A2; } else if (A2 == 0) { y0_2 = (r * sqrt(A2 * A2 + B2 * B2) - C2) / B2; if (B1 == 0) x0_2 = (-1 * r * sqrt(A1 * A1 + B1 * B1) - C1) / A1; else x0_2 = (-1 * r * sqrt(A1 * A1 + B1 * B1) - C1 - B1 * y0_2); } else { x0_2 = ((-1 * r * sqrt(A1 * A1 + B1 * B1) - C1) * abs(B2) + (r * sqrt(A2 * A2 + B2 * B2) - C2) * abs(B1)) / (A1 * abs(B2) + A2 * abs(B1)); y0_2 = (-1 * r * sqrt(A1 * A1 + B1 * B1) - C1 - A1 * x0_2) / B1; } if (A1 == 0) { y0_3 = (r * sqrt(A1 * A1 + B1 * B1) - C1) / B1; if (B2 == 0) x0_3 = (r * sqrt(A2 * A2 + B2 * B2) - C2) / A2; else x0_3 = (r * sqrt(A2 * A2 + B2 * B2) - C2 - B2 * y0_3) / A2; } else if (A2 == 0) { y0_3 = (r * sqrt(A2 * A2 + B2 * B2) - C2) / B2; if (B1 == 0) x0_3 = (r * sqrt(A1 * A1 + B1 * B1) - C1) / A1; else x0_3 = (r * sqrt(A1 * A1 + B1 * B1) - C1 - B1 * y0_3); } else { x0_3 = ((r * sqrt(A1 * A1 + B1 * B1) - C1) * abs(B2) + (r * sqrt(A2 * A2 + B2 * B2) - C2) * abs(B1)) / (A1 * abs(B2) + A2 * abs(B1)); y0_3 = (r * sqrt(A1 * A1 + B1 * B1) - C1 - A1 * x0_3) / B1; } if (A1 == 0) { y0_4 = (-1 * r * sqrt(A1 * A1 + B1 * B1) - C1) / B1; if (B2 == 0) x0_4 = (-1 * r * sqrt(A2 * A2 + B2 * B2) - C2) / A2; else x0_4 = (-1 * r * sqrt(A2 * A2 + B2 * B2) - C2 - B2 * y0_4) / A2; } else if (A2 == 0) { y0_4 = (-1 * r * sqrt(A2 * A2 + B2 * B2) - C2) / B2; if (B1 == 0) x0_4 = (-1 * r * sqrt(A1 * A1 + B1 * B1) - C1) / A1; else x0_4 = (-1 * r * sqrt(A1 * A1 + B1 * B1) - C1 - B1 * y0_4); } else { x0_4 = ((-1 * r * sqrt(A1 * A1 + B1 * B1) - C1) * abs(B2) + (-1 * r * sqrt(A2 * A2 + B2 * B2) - C2) * abs(B1)) / (A1 * abs(B2) + A2 * abs(B1)); y0_4 = (-1 * r * sqrt(A1 * A1 + B1 * B1) - C1 - A1 * x0_4) / B1; } cout << x0_1 << " " << y0_1 << endl; cout << x0_2 << " " << y0_2 << endl; cout << x0_3 << " " << y0_3 << endl; cout << x0_4 << " " << y0_4 << endl; /*if (fabs(abs(A3 * x0_1 + B3 * y0_1 + C3) / sqrt(A3 * A3 + B3 * B3) - r) < fabs(abs(A3 * x0_2 + B3 * y0_2 + C3) / sqrt(A3 * A3 + B3 * B3) - r)) cout << setprecision(8) << fixed << x0_1 << " " << y0_1; else cout << setprecision(8) << fixed << x0_2 << " " << y0_2;*/ }
run
|
edit
|
history
|
help
0
Kadane's Algorithm
DailyExchRate2
RandomMessage
Microsoft - MaxEmployeeAttendence (R repititions - 1st step towards DP solution)
cppPyEnum
Vec+Mem+Adv_11
role of destructor during DMA
Logical AND versus Bitwise AND
Stack with min element
odws