Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Defining a curve path in shapely.geometry

I am using the shapely.geometry library in Python. Right now my path is composed of 2 straight lines (go straight and go left) and I want to make it curve (to make my path smoother and avoid the 90 degree angle). Is there a way to define the path as a curve in the same library? It would be very useful as I am using the library to compute the projection of points into the path... Otherwise, how should I change my entire code?

from shapely.geometry import Point
from shapely.geometry import LineString

x = 7.5
y = 10
vel = 150
angle = 98
velx = vel*math.cos(angle*math.pi/180)
vely = vel*math.sin(angle*math.pi/180)


path = LineString([(5.5, 0), (5.5, 18), (-12.5,18)])

actual = Point(x,y)

future_x = round(actual.coords[0][0]+(t_step*velx),2)
future_y = round(actual.coords[0][1]+(t_step*vely),2)
future = Point(future_x, future_y)

#Get projection of future point + distance 

#Get future projected in the path
projected = path.interpolate(path.project(future))

#Get distance from projected point to future point
vector = (projected.coords[0][0]-future.coords[0][0],projected.coords[0][1]-future.coords[0][1])

distance = np.linalg.norm(vector)

Comments