If the plane is defined as a 4d vector (normal form), we need to find a point on the plane, then calculate the intersection as before (see p_co assignment). # if 'fac' is between (0 - 1) the point intersects with the segment. # The factor of the point between p0 -> p1 (0 - 1) Return a Vector or None (when the intersection can't be found). P_no Is a normal vector defining the plane direction P_co Is a point on the plane (plane coordinate). # intersection functionĭef isect_line_plane_v3(p0, p1, p_co, p_no, epsilon=1e-6): With a Vector data type and operator overloading, it can be more concise (included in example below). Note: This example uses pure functions, without any dependencies - to make it easy to move to other languages. Other details noted in the code-comments. You may want to return this too, because values from 0 to 1 intersect the line segment - which may be useful for the caller. In the examples below (code for both is provided).Īlso note that this function calculates a value representing where the point is on the line, (called fac in the code below). Where the plane can be either a point and a normal, or a 4d vector (normal form), Here is a Python example which finds the intersection of a line and a plane.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |