Given a plane and a 3D point, transform the 3D point to a 2D coordinate along the plane.

Blitz3D Forums/Blitz3D Programming/Given a plane and a 3D point, transform the 3D point to a 2D coordinate along the plane.

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

This should get you started:
Global ProjectX#,ProjectY#,ProjectZ#

;
; x,y,z       = Position of the point
; px,py,pz    = A point on the plane
; pnx,pny,pnz = The plane normal
; returns the shortest distance from the point to the plane
;
Function ProjectPointOnPlane#(x#,y#,z#,px#,py#,pz#,pnx#,pny#,pnz#)
	
	Local sb#, sn#, sd#
	sn = - (pnx*(x-px) + pny*(y-py) + pnz*(z-pz))
	sd = (pnx*pnx + pny*pny + pnz*pnz)
	sb = sn / sd

	ProjectX = x + sb * pnx
	ProjectY = y + sb * pny
	ProjectZ = z + sb * pnz
	
	Return Sqr((x - ProjectX)^2 + (y - ProjectY)^2 + (y - ProjectY)^2)
	
End Function

Fredborg