找回密码
 快速注册
搜索
查看: 40|回复: 0

点到二次曲线的切线

[复制链接]

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-3-3 02:51 |阅读模式
写一个函数, 输入一点和一个二次曲线(geometry.asy定义的conic结构体), 输出点到二次曲线的所有切点?
圆的情形, 见olympiad.asy
点到圆的2个切点(按逆时针标为1和2):
  1. // The nth point of tangency from a point P to the circle with center O and radius r
  2. // where n can be 1 or 2 - the points of tangency are labeled in counterclockwise order around the circle.
  3. // If P is inside the circle, the center of the circle is returned rather than an error.
  4. pair tangent(pair P, pair O, real r, int n=1)
  5. {  
  6.         real d,R;  
  7.         pair X,T;  
  8.         d=abs(P-O);  
  9.         if (d<r) return O;  
  10.         R=sqrt(d^2-r^2);  
  11.         X=intersectionpoint(circle(O,r),O--P);  
  12.         if (n==1)
  13.         {   
  14.                 T=intersectionpoint(circle(P,R),Arc(O,r,degrees(X-O),degrees(X-O)+180));   
  15.         }  
  16.         else if (n==2)
  17.         {   
  18.                 T=intersectionpoint(circle(P,R),Arc(O,r,degrees(X-O)+180,degrees(X-O)+360));   
  19.         }  
  20.         else {T=O;}  
  21.         return T;
  22. }
复制代码

手机版|悠闲数学娱乐论坛(第3版)

GMT+8, 2025-3-4 12:22

Powered by Discuz!

× 快速回复 返回顶部 返回列表