Geometric template of algorithm Summary

Source: Internet
Author: User

1. geometric formula

Triangle:

1. Half perimeter P = (A + B + C)/2

2. area S = AHA/2 = absin (C)/2 = SQRT (P-A) (p-B) (p-C ))

3. midline MA = SQRT (2 (B ^ 2 + C ^ 2)-a ^ 2)/2 = SQRT (B ^ 2 + C ^ 2 + 2 bccos ()) /2

4. ta = SQRT (BC (B + C) ^ 2-A ^ 2)/(B + C) = 2 bccos (A/2)/(B + C)

5. california HA = bsin (c) = Csin (B) = SQRT (B ^ 2-(a ^ 2 + B ^ 2-C ^ 2)/(2a) ^ 2)

6. incircle radius R = s/P = Asin (B/2) sin (C/2)/sin (B + C)/2)

= 4 rsin (A/2) sin (B/2) sin (C/2) = SQRT (P-A) (p-B) (p-C) /P)

= Ptan (A/2) Tan (B/2) Tan (C/2)

7. outer circle radius R = ABC/(4S) = A/(2sin (A) = B/(2sin (B) = C/(2sin (c ))

Quadrilateral:

D1 and D2 are diagonal lines, M is a diagonal point line, and a is a diagonal angle.

1. A ^ 2 + B ^ 2 + C ^ 2 + d ^ 2 = D1 ^ 2 + D2 ^ 2 + 4 m ^ 2

2. S = d1d2sin (a)/2

(The inner Quadrilateral of the following circle)

3. AC + bd = d1d2

4. S = SQRT (P-A) (p-B) (p-C) (p-D), P is the semi-perimeter

Positive n edge shape:

R indicates the outer circle radius, and r indicates the incircle radius.

1. center angle A = 2PI/n

2. Inner angle c = (n-2) PI/n

3. side length a = 2 SQRT (R ^ 2-r ^ 2) = 2 rsin (A/2) = 2 rtan (A/2)

4. area S = NAR/2 = nR ^ 2tan (A/2) = nR ^ 2sin (a)/2 = Na ^ 2/(4tan (A/2 ))

Circle:

1. arc length L = Ra

2. String Length A = 2 SQRT (2hr-h ^ 2) = 2 rsin (A/2)

3. Bow Height H = r-SQRT (R ^ 2-A ^ 2/4) = r (1-cos (A/2) = atan (A/4)/2

4. Slice area S1 = RL/2 = R ^ 2a/2

5. Bow area S2 = (RL-A (R-h)/2 = R ^ 2 (a-sin (A)/2

Prism:

1. Volume V = ah, A is the bottom area, H is high

2. The side area S = LP, L is the rib length, and P is the straight section perimeter.

3. Full area T = S + 2a

Pyramid:

1. Volume V = Ah/3, a is the bottom area, H is high

(The following is a positive pyramid)

2. side area S = LP/2, L is oblique height, p is the bottom perimeter

3. Full area T = S +

Pyramid:

1. Volume V = (A1 + A2 + SQRT (a1a2) h/3, a1.a2 is the upper and lower bottom area, H is high

(The following is the right pyramid)

2. side area S = (P1 + p2) l/2. p1.p2 indicates the perimeter of the upper and lower sides, and l indicates the oblique height.

3. Full area T = S + A1 + A2

Cylindrical:

1. side area S = 2 pirh

2. Full area T = 2pir (H + r)

3. Volume V = PIR ^ 2 h

Cone:

1. Bus L = SQRT (H ^ 2 + R ^ 2)

2. side area S = pirl

3. Full area T = PIR (L + r)

4. Volume V = PIR ^ 2 H/3

Table:

1. Bus L = SQRT (H ^ 2 + (r1-r2) ^ 2)

2. side area S = Pi (R1 + R2) L

3. Full area T = pir1 (L + R1) + pir2 (L + R2)

4. Volume V = Pi (R1 ^ 2 + R2 ^ 2 + r1r2) h/3

Ball:

1. Full area T = 4pir ^ 2

2. Volume V = 4pir ^ 3/3

Arena:

1. side area S = 2 pirh

2. Full area T = Pi (2RH + R1 ^ 2 + R2 ^ 2)

3. Volume V = PIH (3 (R1 ^ 2 + R2 ^ 2) + H ^ 2)/6

Ball slice:

1. Full area T = PIR (2 H + R0), h indicates the height of the Ballon crown, and R0 indicates the radius of the bottom of the Ballon crown.

2. Volume V = 2pir ^ 2 H/3

Binary geometric template

1. Point struct

1 struct point2 {3     double x;4     double y;5 }

2. Crossover:

1/* P0 is a common vertex */2 double xmult (point P1, point P2, point P0) {3 return (p1.x-forwarded X) * (p2.y-forwarded y) -(p2.x-Snapshot X) * (p1.y-Snapshot y); 4}

3. Two-Point distance:

1 double dis(point p1,point p2){2     return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));3 }

4. Graham algorithm for the sorting of convex packet points CMP:

1 bool cmp(point a,point b)2 {3     if (CrossMul(a,b,p[1])>0 ||4             (CrossMul(a,b,p[1])==0&&dis(a,p[1])<dis(b,p[1]))) return true;5     return false;6 }

5. convex hull: 1) distance between two points 2) area 3) perimeter

1 int main () 2 {3 int N, I, j, top; 4 While (CIN> N) 5 {6 for (I = 1; I <= N; I ++) 7 {8 CIN> P [I]. x> P [I]. y; 9 If (P [I]. Y <p [1]. Y | (P [I]. y = P [1]. Y & P [I]. x <p [1]. x) 10 swap (P [1], p [I]); 11} 12 sort (p + 2, P + n + 1, CMP); 13 Top = 0; 14 Q [++ top] = P [1]; 15 Q [++ top] = P [2]; 16 for (I = 3; I <= N; I ++) 17 {18 while (top> 1 & crossmul (Q [Top], p [I], Q [Top-1]) <0) Top --; 19 Q [++ top] = P [I]; 20} 21/* convex hull diameter */22 int max = int_min; 23 for (INT I = 1; I <= top; I ++) 24 for (Int J = 1; j <I; j ++) 25 max = max> dis_2 (Q [I], Q [J])? MAX: dis_2 (Q [I], Q [J]); 26 printf ("% d \ n", max ); 27/* Convex Hull area */28 int area = 0; 29 for (INT I = 2; I <= top; I ++) 30 area + = crossmul (Q [I], Q [I + 1], Q [1]); 31 printf ("% d \ n", ABS (area )); 32/* convex hull perimeter */33 double sum = DIS (Q [1], Q [2]); 34 for (I = 3; I <= top; I ++) 35 sum + = DIS (Q [I], Q [I-1]); 36 sum + = DIS (Q [1], Q [Top]); 37 printf ("% d", sum); 38} 39 return 0; 40}

 

(To be continued)

 

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.