0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

sympyで線分上の最も近い点

Last updated at Posted at 2017-02-02
#sympyで線分上の最も近い点
from sympy import Point, Segment
senbun1 = Segment(Point(0, 0), Point(1, 1))
senbun2 = senbun1.perpendicular_bisector(Point(1, 0))
asi=senbun2.p1
print(asi)
print(float(asi.x),float(asi.y))

(結果)
Point2D(1/2, 1/2)
0.5 0.5
(参考)

--------------
【補足】(2018/07/08)

(20220901)

sympyで

from sympy import *
print("#",Segment(Point(0, 0), Point(1, 1)).perpendicular_bisector(Point(1, 0)))
# Segment2D(Point2D(1, 0), Point2D(1/2, 1/2))
from sympy import *
print("#",Line(Point(0, 0), Point(1,1)).projection(Point(1, 0)))
# Point2D(1/2, 1/2)
0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?