简体   繁体   中英

Calculating a point inside a polygon

Let's say that we have a 3d polygon that is defined with three points

  • x1, y1, z1
  • x2, y2, z2
  • x3, y3, z3

Then we have a perpendicular to the Z axis ray with position rX, rY. How can we find out if the ray is hitting the polygon and in what X,Y,Z the collision is happening.

Any code example will be very useful.

For intersection of a vector with a triangle in 3D, see http://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm . You'll need to add your own cross-product (CROSS), dot-product (DOT), and sub-vector (SUB) code for the pseudo-code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM