Skip to content

Commit

Permalink
function to detect if a point is on left or right side of track
Browse files Browse the repository at this point in the history
  • Loading branch information
mdvandamme committed Dec 4, 2024
1 parent 2e75828 commit b2ade52
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 4 additions & 4 deletions test/algo/test_cinematics.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
computeSwitchbacks,
smoothed_speed_calculation,
computeAbsCurv,
computeAbsCurvAnotherPoint,
# computeAbsCurvAnotherPoint,
estimate_heading,
computeAvgSpeed,
computeAvgAscSpeed,
Expand Down Expand Up @@ -284,9 +284,9 @@ def testAbsCurv(self):
self.assertEqual(self.trace1.getObsAnalyticalFeature(BIAF_ABS_CURV, 2), 20)
self.assertEqual(self.trace1.getObsAnalyticalFeature(BIAF_ABS_CURV, 8), 90)

self.assertEqual(computeAbsCurvAnotherPoint(self.trace1, 1, 1), 1)
self.assertEqual(computeAbsCurvAnotherPoint(self.trace1, 18, 8), 28)
self.assertEqual(computeAbsCurvAnotherPoint(self.trace1, 57, 35), 87)
#self.assertEqual(computeAbsCurvAnotherPoint(self.trace1, 1, 1), 1)
#self.assertEqual(computeAbsCurvAnotherPoint(self.trace1, 18, 8), 28)
#self.assertEqual(computeAbsCurvAnotherPoint(self.trace1, 57, 35), 87)


def testEstimateHeading(self):
Expand Down
3 changes: 2 additions & 1 deletion tracklib/algo/cinematics.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def computeCurvAbsBetweenTwoPoints(track, id_ini=0, id_fin=None):
return s


'''
def computeAbsCurvAnotherPoint(track, x, y):
"""Computes the curvilinear abscissa of the projection of a point onto a track"""
distmin, xproj, yproj, iproj = proj_polyligne(track.getX(), track.getY(), x, y)
Expand All @@ -169,7 +170,7 @@ def computeAbsCurvAnotherPoint(track, x, y):
d = track[iproj].distanceTo(Obs(ENUCoords(xproj, yproj), ObsTime()))
s = computeCurvAbsBetweenTwoPoints(track, 0, iproj) + d
return s

'''

def computeNetDeniv(track, id_ini=0, id_fin=None):
"""Computes net denivellation (in meters)"""
Expand Down
7 changes: 6 additions & 1 deletion tracklib/util/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,12 @@ def detect_side(track, x, y, seuilMemeProj=0.1):

dist, xp, yp = proj_segment([xa, ya, xb, yb], x, y)

abscurv = tracklib.computeAbsCurvAnotherPoint(track, xp, yp)
# abscurv = tracklib.computeAbsCurvAnotherPoint(track, xp, yp)
if iproj == 0:
abscurv = track.getFirstObs().distanceTo(tracklib.Obs(tracklib.ENUCoords(xp, yp), tracklib.ObsTime()))
else:
d = track[iproj].distanceTo(tracklib.Obs(tracklib.ENUCoords(xp, yp), tracklib.ObsTime()))
abscurv = tracklib.computeCurvAbsBetweenTwoPoints(track, 0, iproj) + d

if pdt > 0:
SIDES.append((dist, xp, yp, 1, abscurv))
Expand Down

0 comments on commit b2ade52

Please sign in to comment.