Calculate distance between point and plane (3-matic 14)

This script calculates the distance between a point and a plane.

# This script will find the distance between a point and plane
# Input: a project where there are two objects called 'point' and 'plane'. 
# Output: distance in mm
# Note: the distance is not given in absolute values, so you can determine if
#       the point is in front or behind the plane
# Author: Kristof Godelaine (Materialise) 
# Version: 1.0 (28 June 2017) 

def distance_point_to_plane(pt, pl):
	#info Of plane
	normal = pl.z_axis
	pt_org = trimatic.create_point(pl.origin)
	a = normal[0]
	b = normal[1]
	c = normal[2]
	x0 = pt_org.x
	y0 = pt_org.y
	z0 = pt_org.z

	#info of point
	tx = pt.x
	ty = pt.y
	tz = pt.z

	#distance calculation
	dist = (a*tx + b*ty + c*tz + (-a*x0 -b*y0 -c*z0))/((a**2 + b**2 + c**2)**0.5)
	return dist

#point = trimatic.create_point((12,6,3))
#plane = trimatic.create_plane_3_points((0,0,0),(1,0,0),(0,1,0))