# Circle of the outer circle of a triangle

Source: Internet
Author: User

Given three points to find the center, I had a silly practice before.
Find the vertical lines of the two sides, and then calculate the intersection point.
Why do I come here with this?
Instead of simply listing three equations to solve the equation?
The reason for my careful consideration is that the high school teacher told us that the Center Coordinate should be the center vertical line.
Also true
The midpoint coordinates are obtained directly, and then the vertical line equation is obtained directly in the oblique method.
Then the intersection of two straight lines is solved.
This simplifies the computing complexity.
But !!!
Now I am a programming solution ~ Computation is handed over to the computer.

Same question poj1329

Using the former method, I typed more than 100 rows.Code. (Maybe I'm too frustrated)
However, I only use 60 lines of code.

Use different methods for different conditions ~~

Point circumcenter (point P0, Point P1, point P2)
{
Point ret;
Double a1 = p1.x-fill X, b1 = p1.y-fill y, C1 = (sqr (A1) + sqr (B1)/2;
Double a2 = p2.x-records X, b2 = p2.y-records y, C2 = (sqr (A2) + sqr (B2)/2;
Double D = A1 * B2-A2 * B1;
Ret. x = forward X + (C1 * B2-C2 * B1)/d;
Ret. Y = 127y + (A1 * C2-A2 * C1)/d;
Return ret;
}
The function reads P0, P1, and P2 points, and returns the outer circle center of the triangle.

List Equations
Sqr (O. x-p0.x) + sqr (O. y-p0.y) = sqr (r); (1)
Sqr (O. x-p0.x) + sqr (O. y-p0.y) = sqr (r); (2)
Sqr (O. x-p0.x) + sqr (O. y-p0.y) = sqr (r); (3)
Simultaneous (1) (2)
(P1.x-Snapshot X) * o. X + (p1.y-Policy) * o. y = (sqr (p1.x) + sqr (p1.y)-sqr (p0.x)-sqr (p0.y)/2; (4)
Simultaneous (1) (3)
(P2.x-Snapshot X) * o. X + (p2.y-Policy) * o. y = (sqr (p2.x) + sqr (p2.y)-sqr (p0.x)-sqr (p0.y)/2; (5)
Make o. x = running X + X;
O. Y = 127y + Y;
After being imported (4) (5), the data is simplified
(P1.x-0000x) * x + (p1.y-0000y) * Y = (sqr (p1.x-0000x) + sqr (p1.y-0000y)/2;
(P2.x-p0.x) * x + (p2.y-p0.y) * Y = (sqr (p2.x-p0.x) + sqr (p2.y-p0.y)/2;
Separate solutions (x, y)
P0 + (x, y) = O;

`# Include <iostream> # include <cstdio> # include <cmath> using namespace STD; struct point {Double X, Y;} P0, P1, P2, RET; double sqr (Double X) {return x * X;} Double R; point circumcenter (point P0, Point P1, point P2) {point ret; double a1 = p1.x-Hangzhou X, b1 = p1.y-p0.y, C1 = (sqr (A1) + sqr (B1)/2; double a2 = p2.x-p0.x, b2 = p2.y-p0.y, c2 = (sqr (A2) + sqr (B2)/2; double D = A1 * B2-A2 * B1; ret. X = forward X + (C1 * B2-C2 * B1)/d; ret. y = p0.y + (A1 * C2-A2 * C1)/d; return ret;} void out (Double X) {If (x <0) {printf ("+ %. 3lf ",-x);} elseif (x> 0) {printf ("-%. 3lf ", x) ;}} int main () {freopen (" in.txt "," r ", stdin); freopen (" out1.txt "," W ", stdout ); int test = 0; while (CIN> running x> running y> p1.x> p1.y> p2.x> p2.y) {// ++ test; // If (test> 1) ret = circumcenter (P0, P1, P2); r = SQRT (sqr (Ret. x-p0.x) + sqr (Ret. y-p0.y); printf ("(X"); Out (Ret. x); printf (") ^ 2 + (Y"); Out (Ret. y); printf (") ^ 2 = %. 3lf ^ 2 \ n ", R); printf (" x ^ 2 + y ^ 2 "); Out (Ret. x * 2); printf ("X"); Out (Ret. y * 2); printf ("Y"); Out (sqr (R)-sqr (Ret. x)-sqr (Ret. y); printf ("= 0 \ n"); printf ("\ n");} return 0 ;}`

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.