设已知点A(p,q),任意直线ax + by + c = 0 (a,b不同时为0),A关于该直线的对称点为A'(p',q')
a = 0时b = 0,直线与一个坐标轴平行,应当很容易做,这里省略.
ax + by + c = 0
y = -ax/b - c/b
斜率k = -a/b
AA'⊥直线,AA'斜率k' = -1/k = b/a = (q' - q)/(p' - p) (i)
AA'的中点M((p + p')/2,(q + q')/2)在该直线上:
a(p + p')/2 + b(q + q') + c = 0 (ii)
联立(i)(ii)即可得出p',q