def PlaneFromPointNormal(sourcePoint, sourceNormal): from Vector3Math import Vector3 result = Plane.New() result.a = sourceNormal.x result.b = sourceNormal.y result.c = sourceNormal.z result.d = -Vector3.Dot(sourcePoint, sourceNormal) return result
def PlaneIntersectLine(self, p1, p2): from Vector3Math import Vector3 normal = Vector3(self.a, self.b, self.c) direction = p2 - p1 dotVal = Vector3.Dot(normal, direction) if dotVal == 0.0: return -1 temp = (self.d + Vector3.Dot(normal, p1)) / dot result = Vector3.New() result.x = p1.x - temp * direction.x result.y = p1.y - temp * direction.y result.z = p1.z - temp * direction.z return result