Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2071 | zjchen | 1 | !goto $wims_read_parm |
2 | |||
3 | :def |
||
4 | title=Triangle with given vertices |
||
5 | synonyme=triangle with vertices |
||
6 | input=data2d |
||
7 | !exit |
||
8 | |||
9 | :proc |
||
10 | !if $cnt!=3 |
||
11 | error=bad_formula |
||
12 | !exit |
||
13 | !endif |
||
14 | !distribute lines $fml into A,B,C |
||
15 | pari_header=M=[$fml2]; A=M[1,]; B=M[2,]; C=M[3,];\ |
||
16 | t1=B-C; s1=sqrt(t1[1]^2+t1[2]^2);\ |
||
17 | t2=A-C; s2=sqrt(t2[1]^2+t2[2]^2);\ |
||
18 | t3=A-B; s3=sqrt(t3[1]^2+t3[2]^2); |
||
19 | result=!exec pari print(s1);\ |
||
20 | print(s2);\ |
||
21 | print(s3);\ |
||
22 | area=abs(t1[1]*t2[2]-t1[2]*t2[1])/2;print(area);\ |
||
23 | r1=acos((t2[1]*t3[1]+t2[2]*t3[2])/(s2*s3));print(r1);\ |
||
24 | r2=acos(-(t1[1]*t3[1]+t1[2]*t3[2])/(s1*s3));print(r2);\ |
||
25 | r3=pi-r1-r2;print(r3);\ |
||
26 | d1=r1*180/pi;print(d1);\ |
||
27 | d2=r2*180/pi;print(d2);\ |
||
28 | d3=r3*180/pi;print(d3);\ |
||
29 | h1=area/s1*2;print(h1);\ |
||
30 | h2=area/s2*2;print(h2);\ |
||
31 | h3=area/s3*2;print(h3);\ |
||
32 | ri=2*area/(s1+s2+s3);print(ri);\ |
||
33 | rc=(s1*s2*s3)/(4*area);print(rc);\ |
||
34 | bc=(A+B+C)/3; print(bc); |
||
35 | !distribute lines $result into s1,s2,s3,area,r1,r2,r3,d1,d2,d3,h1,h2,h3,\ |
||
36 | ri,rc,bc |
||
37 | l=!nonempty lines $result |
||
38 | c=!linecnt $l |
||
39 | !if $c<16 |
||
40 | result= |
||
41 | !endif |
||
42 | insdraw_size=200,200 |
||
43 | !exit |
||
44 | |||
45 | :output |
||
46 | Plane triangle with 3 vertices |
||
47 | !distribute items $fml3 into aa,bb,cc |
||
48 | !htmlmath A = $aa, B = $bb, C = $cc |
||
49 | :<p> |
||
50 | Side AB = $[$s3]<br> |
||
51 | Side BC = $[$s1]<br> |
||
52 | Side AC = $[$s2]<br> |
||
53 | Area = $[$area]<br> |
||
54 | Angle A = $[$d1]° = $[$r1] radians<br> |
||
55 | Angle B = $[$d3]° = $[$r3] radians<br> |
||
56 | Angle C = $[$d2]° = $[$r2] radians<br> |
||
57 | Altitude to side AB = $[$h2]<br> |
||
58 | Altitude to side BC = $[$h1]<br> |
||
59 | Altitude to side AC = $[$h3]<p> |
||
60 | Incircle radius = $[$ri]<br> |
||
61 | Circumcircle radius = $[$rc]<br> |
||
62 | Barycenter = ($bc)<br> |
||
63 | |||
64 | <center> |
||
65 | !!insdraw xrange $X1,$X2\ |
||
66 | yrange $Y1,$Y2\ |
||
67 | linewidth 2\ |
||
68 | polygon blue,0,0,$s3,0,$x,$y\ |
||
69 | fcircle 0,0,6,red\ |
||
70 | fcircle $s3,0,6,red\ |
||
71 | fcircle $x,$y,6,red\ |
||
72 | text black,$s3*0.4,-0.05*$s3,small,$s3\ |
||
73 | text black,0.55*$x,0.5*$y,small,$s2\ |
||
74 | text black,0.53*($s3+$x),0.6*$y,small,$s1\ |
||
75 | text red,-0.08*$s3,0,small,A\ |
||
76 | text red,1.05*$s3,0,small,C\ |
||
77 | text red,$x+0.05*$s3,$y+0.08*$s3,small,B |
||
78 | |||
79 | </center> <br> |
||
80 | !exit |
||
81 |