Forgot password?
 Create new account
View 126|Reply 0

在olympiad.asy和geometry.asy中有两个函数都叫bisectorpoint

[Copy link]

3148

Threads

8489

Posts

610K

Credits

Credits
66148
QQ

Show all posts

hbghlyj Posted at 2023-3-3 03:07:27 |Read mode
Klaus-Anton's blog讲到,
在olympiad.asy和geometry.asy中有两个函数都叫bisectorpoint
但是它们接收的输入类型不同, 所以不会冲突.
若输入的类型是side, 如triangle t=triangle(A,B,C); point D=bisectorpoint(t.AB);
那么由geometry.asy中的bisectorpoint处理, 输出的是所给边对应的角平分线与所给边的交点(下图中的$D$).
而若输入的类型是3个点, 如label("$\gamma_1$", C,6*dir(C--bisectorpoint(A,C,D)),red);
那么由olympiad.asy中的bisectorpoint处理, 输出的是角平分线上到顶点为1的点(下图中的$E$).
因为这里无法使用olympiad.asy, 下图是从Aops复制的代码, 需要做以下调整:
由$D$定义$E$: pair myE=C+unit(D-C);
将bisectorpoint的输入类型换为side: label("$\gamma_1$", C,6*dir(C--bisectorpoint(t2.AB)),red);

geometry.asy第6109行bisectorpoint是用trilinear coordinates定义的:
  1. point bisectorpoint(side side)
  2. {
  3.   triangle t = side.t;
  4.   int n = numarray[abs(side.n) - 1];
  5.   if(n == 1) return trilinear(t, 1, 1, 0);
  6.   if(n == 2) return trilinear(t, 0, 1, 1);
  7.   return trilinear(t, 1, 0, 1);
  8. }
Copy the Code

在olympiad.asy中bisectorpoint的定义为
  1. // The point on the angle bisector of <ABC that is a unit distance from B.
  2. // If only two points A and B are specified, the function returns a point
  3. // on the perpendicular bisector of AB, a unit distance from the segment.
  4. pair bisectorpoint(pair A ... pair[] BC)
  5. {
  6.     pair P,B,C,M;
  7.     if (BC.length==1)
  8.     {  
  9.         B=BC[0];  
  10.         M=midpoint(A--B);  
  11.         P=unit(rotate(90,M)*A-M)+M;
  12.     }
  13.     else if (BC.length==2)
  14.     {  
  15.         B=BC[0];  
  16.         C=BC[1];  
  17.         P=unit(midpoint((unit(A-B)+B)--(unit(C-B)+B))-B)+B;
  18.     }
  19.     return P;
  20. }
Copy the Code

其中, pair A ... pair[] BC是指输入任意多点, 第一个存入pair A, 其余的存入pair[] BC
当输入共2个点$A,B$, 输出它们的垂直平分线上的到$AB$中点距离为1的点$P$(且$PBA$是逆时针转向).
当输入共3个点$A,B,C$, 输出$\angle ABC$的平分线上的到$B$距离为1的点$P$.
它的构造很简单:
BC.length==1是指输入共2个点, 作$AB$中点$M$, 然后P=unit(rotate(90,M)*A-M)+M; 把$A$关于$M$旋转90°, 减去$M$得到AB的法向量, 它的单位向量加上$M$得到$AB$的垂直平分线上的到$M$距离为1的点.
BC.length==2是指输入共3个点, (unit(A-B)+B)得到$AB$上到$A$距离为1的点, (unit(C-B)+B))得到$BC$上到$A$距离为1的点, 则其中点在$\angle ABC$的平分线上, 取它到$B$的单位向量, 再加$B$, 就作出了$\angle ABC$的平分线上的到$B$距离为1的点$P$.

手机版Mobile version|Leisure Math Forum

2025-4-20 12:16 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list