Forgot password?
 Register account
View 154|Reply 0

点到二次曲线的切线

[Copy link]

3158

Threads

7933

Posts

45

Reputation

Show all posts

hbghlyj posted 2023-3-3 02:51 |Read mode
写一个函数, 输入一点和一个二次曲线(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. }
Copy the Code

Quick Reply

Advanced Mode
B Color Image Link Quote Code Smilies
You have to log in before you can reply Login | 快速注册

$\LaTeX$ formula tutorial

Mobile version

2025-6-8 07:00 GMT+8

Powered by Discuz!

Processed in 0.027888 second(s), 21 queries

× Quick Reply To Top Edit