Created
March 13, 2017 14:13
-
-
Save NiklasRosenstein/4ec843958c3947060d29c2f0234cd92e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import c4d | |
def calc_line_plane_intersection(o, d, a, n): | |
""" | |
Calculates the intersection of the line described by *o* and *d* | |
with the plane described by *a* and *n*. | |
""" | |
dot = d.Dot(n) | |
if abs(dot) < 1.0e-7: return None # parallel to plane | |
dist = (a - o).Dot(n) / dot | |
return o + d * (dist / d.GetLength()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment