|
> No.3145[元記事へ]
!●平面の点を「平面のベクトルとみる」と「複素数とみる」と考えられる
OPTION ARITHMETIC COMPLEX
SET WINDOW -8,8,-8,8 !表示領域を設定する
DRAW grid !XY座標
LET OA=v(-6,-5) !頂点の座標x,y ※反時計まわり
LET OB=v( 6,-4)
LET OC=v(-1, 6)
LET OD=v(-5, 3)
CALL gcLINE(OA,OB,"A","") !四角形を描く
CALL gcLINE(OB,OC,"B","")
CALL gcLINE(OC,OD,"C","")
CALL gcLINE(OD,OA,"D","")
!●重心(幾何的重心)
LET Oo=v(0,0) !原点
LET S1=fnCROSS(OA,OB)/2 !三角形OABの符号つき面積
LET G1=(Oo+OA+OB)/3 !三角形OABの重心
LET S2=fnCROSS(OB,OC)/2
LET G2=(Oo+OB+OC)/3
LET S3=fnCROSS(OC,OD)/2
LET G3=(Oo+OC+OD)/3
LET S4=fnCROSS(OD,OA)/2
LET G4=(Oo+OD+OA)/3
LET OG=(S1*G1+S2*G2+S3*G3+S4*G4)/(S1+S2+S3+S4) !(ΣS[k]*G[k])/(ΣS[k])
CALL gcPOINT(OG,"G") !重心
PRINT OG
!●重心(物理的重心)
LET OGG=(OA+OB+OC+OD)/4
CALL gcPOINT(OGG,"G'") !重心
PRINT OGG
PRINT
!検算
SET LINE COLOR 3
CALL gcLINE(OA,OC,"","") !対角線
CALL gcLINE(OB,OD,"","")
SET LINE COLOR 4
CALL gcDIVIDE(OA,OB,1,2,"1", W1) !辺ABを3等分
CALL gcDIVIDE(OA,OB,2,1,"2", W2)
CALL gcDIVIDE(OB,OC,1,2,"3", W3) !辺BC
CALL gcDIVIDE(OB,OC,2,1,"4", W4)
CALL gcDIVIDE(OC,OD,1,2,"5", W5) !辺CD
CALL gcDIVIDE(OC,OD,2,1,"6", W6)
CALL gcDIVIDE(OD,OA,1,2,"7", W7) !辺DA
CALL gcDIVIDE(OD,OA,2,1,"8", W8)
CALL gcINTERSECTION(W8,W1,W2,W3,"", OP,K) !交点
CALL gcINTERSECTION(W2,W3,W4,W5,"", OQ,K)
CALL gcINTERSECTION(W4,W5,W6,W7,"", OR,K)
CALL gcINTERSECTION(W6,W7,W8,W1,"", OS,K)
CALL gcLINE(OP,OQ,"P","") !平行四辺形
CALL gcLINE(OQ,OR,"Q","")
CALL gcLINE(OR,OS,"R","")
CALL gcLINE(OS,OP,"S","")
CALL gcLINE(OP,OR,"","") !対角線
CALL gcLINE(OQ,OS,"","")
CALL gcINTERSECTION(OP,OR,OQ,OS,"", OG,K) !交点
PRINT OG
END
※サブルーチン部分は省略した。
実行結果
(-1.01495726495726 -.566239316239316)
-1.5
(-1.01495726495726 -.566239316239316)
|
|