Skip to content

Instantly share code, notes, and snippets.

@NiklasRosenstein
Created March 13, 2017 14:13
Show Gist options
  • Save NiklasRosenstein/4ec843958c3947060d29c2f0234cd92e to your computer and use it in GitHub Desktop.
Save NiklasRosenstein/4ec843958c3947060d29c2f0234cd92e to your computer and use it in GitHub Desktop.
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