Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary actions in angle caclulation #9

Open
sergeyshashmurin opened this issue Nov 23, 2022 · 0 comments
Open

Unnecessary actions in angle caclulation #9

sergeyshashmurin opened this issue Nov 23, 2022 · 0 comments

Comments

@sergeyshashmurin
Copy link

sergeyshashmurin commented Nov 23, 2022

Hello! Your repo is very helpful for me!
But I find one unnecessary action in your code. Your func calcVectorAngle is unnecessary
Your code in line_boundary_check.py:

def calcVectorAngle( point1, point2, point3, point4 ):
  u = np.array(line_vectorize(point1, point2))
  v = np.array(line_vectorize(point3, point4))
  i = np.inner(u, v)
  n = LA.norm(u) * LA.norm(v)
  c = i / n
  a = np.rad2deg(np.arccos(np.clip(c, -1.0, 1.0)))
  if u[0]*v[1]-u[1]*v[0]<0:
    return a
  else:
    return 360-a

Your code in test-line-cross-area-intrusion.py:

    if intersect == True:
        angle = calcVectorAngle(traj_p0, traj_p1, bLine_p0, bLine_p1)   # Calculate angle between trajectory and boundary line
        if angle<180:
            boundary_line.count1 += 1
        else:
            boundary_line.count2 += 1

What I suggest:

def calc_orientation(point1, point2, point3, point4):
    u = np.array(line_vectorize(point1, point2))
    v = np.array(line_vectorize(point3, point4))
    return u[0] * v[1] - u[1] * v[0] < 0

    if intersect == True:
        if calc_orientation(traj_p0, traj_p1, bLine_p0, bLine_p1):
            boundary_line.count1 += 1
        else:
            boundary_line.count2 += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant