A method for finding two straight intersection points and triangular inner and outer cores in Java _java

Source: Internet
Author: User

One. To find two lines of intersection

Copy Code code as follows:

Class Point {
Double X;
Double y;

Public Point () {
this.x = 0;
This.y = 0;
}
}
Class Line {
Point A;
Point B;

Public Line () {
THIS.A = new Point ();
this.b = new Point ();
}
Find the intersection of two straight lines, the same slope res=u.a
Point intersection (line U,line v) {
Point res = U.A;
Double T = ((u.a.x-v.a.x) * (V.B.Y-V.A.Y)-(U.A.Y-V.A.Y) * (v.b.x-v.a.x))
/((u.a.x-u.b.x) * (V.B.Y-V.A.Y)-(U.A.Y-U.B.Y) * (v.b.x-v.a.x));
Res.x + = (u.b.x-u.a.x) *t;
Res.y + = (u.b.y-u.a.y) *t;
return res;
}

Two. Find the triangle Circumcenter
1. Vertical heart: The triangle three edge of the high intersection at a point. This is called the triangle of the vertical heart.
2. Center of gravity: three lines on the edge of the triangle are handed at a point. This is called the center of gravity of the triangle.
3. Circumcenter: Triangle Three sides of the perpendicular bisector to a point. This is the center of the Triangle Circumcircle.
4. Inner triangle three angles of internal angle are handed to one point. This is the center of the Triangle InCircle.
Known round of 3 points, first to find 3 sides long, by Helen Formula to draw area s=sqrt (p* (p-a) * (p-b) * (p-c)) p= (a+b+c)/2; by Triangle area Formula S=1/2*a*b*sin (c) and sine theorem A/sin (a) =b/sin (b) =c /sin (C) = diameter (according to the same chord length corresponding to the circumference angle of the same proof sine theorem) can be =a*b*c/2/s diameter.
Find the center coordinates. The necessary and sufficient condition of using: G is ⊿abc circumcenter (vector ga+ vector GB) • Vector ab= (vector gb+ vector gc) • Vector bc= (vector gc+ vector ga), vector ca= vector 0.
The proof of this nature is easy, just think of Circumcenter is the perpendicular bisector intersection can prove this property, the use of vectors can avoid the slope, and consider the slope does not exist in many cases.

Copy Code code as follows:

Triangle Circumcircle Center (circumcenter)
Point Center (Point A,point b,point c) {
Plus this. The compiler hint was not initialized, because new so also wrote the construction method
Line U = New Line (), V = new Line ();
u.a.x= (a.x+b.x)/2;
u.a.y= (A.Y+B.Y)/2;
u.b.x=u.a.x+ (U.A.Y-A.Y);
u.b.y=u.a.y-(u.a.x-a.x);
v.a.x= (a.x+c.x)/2;
v.a.y= (A.Y+C.Y)/2;
v.b.x=v.a.x+ (V.A.Y-A.Y);
v.b.y=v.a.y-(v.a.x-a.x);
return intersection (U,V);
}


Three. Find the inner triangle
Because the inner distance is the radius r, you can divide the triangle into three parts and then get the radius r=2*s/(a+b+c) According to Helen's formula.
InCircle Center Coordinates (X,Y): the coordinates of the three vertices of a triangle: a (x1,y1), B (X2,y2), and C (X3,Y3) The center of the Circle is x= (x1*bc+x2*ca+x3*ab)/(AB+BC+CA), y= (Y1*BC+Y2*CA+Y3*AB)/( AB+BC+CA).
Proof: The heart is the intersection point of the angle equal line, to the three-side distance equals.
Set: In the triangular ABC, the coordinates of the three vertices are: a (x1,y1), B (X2,y2), C (x3,y3) bc=a,ca=b,ab=c, Inner m (x,y) with ama+bmb+cmc=0 (three vectors), ma= (x1-x,y1-y), mb= ( X2-X,Y2-Y), mc= (x3-x,y3-y)
Then: A (x1-x) +b (x2-x) +c (x3-x) =0,a (y1-y) +b (y2-y) +c (y3-y) =0
∴x= (AX1+BX2+CX3)/(A+b+c), y= (ay1+by2+cy3)/(A+B+C)
∴m ((AX1+BX2+CX3)/(A+b+c), (ay1+by2+cy3)/(A+b+c)).

Known as the triangle ABC heart, A,B,C is the A.B.C side of the side length. Then aoa+bob+coc=0 (Oa,ob,oc Point)

Proof: Set the triangle Abc,ad as the angle of the side of the BC Line, the heart is O.
| bc|=a,| ac|=b,| Ab|=c
Aoa+bob+coc
=aoa+b (Ab+oa) +c (Ac+oa)
= (a+b+c) oa+b (db-da) +c (DC-DA)
to set the direction vector e of the BC, then db=e| db|,dc=-e| dc| The
is also divided by the angle line theorem, | db|/| dc|=c/b, so bdb+cdc=0
(a+b+c) oa+b (db-da) +c (Dc-da) = (a+b+c) oa-b da-c DA =aoa+ (b+c) OD
is also due to OA, OD reversal, using the angular line theorem and the ratio theorem:
b/cd=c/bd= (b+c)/(CD+BD) = (b+c)/A, b/cd=oa/od,
so oa/od= (b+c)/A, and because OA, OD reverse,
so aoa+bob+coc=aoa+ (b+c) OD =0.

Contact Us

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.