LoginSignup
6
3

More than 1 year has passed since last update.

sympyで円と円の交点

Last updated at Posted at 2017-02-01
#sympyで円と円の交点
import sympy.geometry as sg

center = sg.Point(0,0)
radius = 10
circle1 = sg.Circle(center, radius)

center = sg.Point(10,0)
radius = 10
circle2 = sg.Circle(center, radius)

result = sg.intersection(circle1,circle2 )

print(result)
print(len(result))
print(float(result[0].x),float(result[0].y),float(result[1].x),float(result[1].y))

#(結果)#pycharm
#[Point2D(5, 5*sqrt(3)), Point2D(5, -5*sqrt(3))]
#2
#5.0 8.660254037844387 5.0 -8.660254037844387
#
#(結果)#SymPy Live Online Shell#精度がいいかも 
#http://live.sympy.org/
#[Point2D(5, 5*sqrt(3)), Point2D(5, -5*sqrt(3))] 
#2 
#(5.0, 8.6602540378443873, 5.0, -8.6602540378443873)
#
# (参考)#Pythonで円とか線とか線分の交点を求める+普通の値に戻す
# http://kamiwo-koete.hatenablog.jp/entry/2014/12/23/193018

参考

3次元:3つの球の交点計算

6
3
6

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3