Skip to content

There is No intersect point returned by Mesh.intersect_with_line(). #931

Discussion options

You must be logged in to vote

Hi Marco,
Here is my solution:
😊

  def findIntersection(Ray, PolyMesh):
    tpoints=PolyMesh.points()
    ray0=np.array(Ray[0])
    ray1=np.array(Ray[1])
    ray_n1=ray1-ray0
    int_pt=None
    for itriangle in PolyMesh.faces():
      p0,p1,p2=[tpoints[itriangle[iv]] for iv in range(3)]
      plane_normal=np.cross(p1-p0,p2-p0)
      tdot=np.dot(plane_normal,ray_n1)
      if abs(tdot) !=0:
        ray_scalar=np.dot(p0-ray0,plane_normal)/np.dot(ray_n1,plane_normal)
        int_pt=ray0+ray_scalar*ray_n1
        # check the intersection falls inside the itriangle
        area0=np.linalg.norm(plane_normal) #itriangle area
        area1=np.linalg.norm(np.cross(p0-int_pt,p1-int_pt))+np.linalg.n…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@ZiguoAtGitHub
Comment options

@ZiguoAtGitHub
Comment options

Answer selected by marcomusy
Comment options

You must be logged in to vote
1 reply
@ZiguoAtGitHub
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants