Skip to content

Commit

Permalink
Merge pull request #64 from kushal2000/patch-2
Browse files Browse the repository at this point in the history
Added nearest_point_on_line function to Line class
  • Loading branch information
thebhatman authored Jun 23, 2019
2 parents 374e69f + bf0d1ca commit 6fe6ee9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion utils/math_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,13 @@ def normalized_vector(self):
# angle = math.atan(self.slope)
angle = self.angle
return Vector2D(math.cos(angle), math.sin(angle))


def nearest_point_on_line(self,point):
t=(point.y-self.point.y)*math.sin(self.angle)+(point.x-self.point.x)*(math.cos(self.angle))
x1=self.point.x+math.cos(self.angle)*t
y1=self.point.y+math.sin(self.angle)*t
point=Vector2D(x1,y1)
return point

##
## @var slope
Expand Down

0 comments on commit 6fe6ee9

Please sign in to comment.