Tuesday, October 2, 2007

HP-35s Euclid Implementation - X : Closest point on a plane to a point

The closest point on a plane to a point P is P-(P*N+d)*N where N is the plane's normalized normal vector and d is the plane's distance to origo (* is here the dot product).

Since the program P stores N in variable N and d in variable O the following short program computes the closest point on the plane entered using program P if the point's positional vector is in the X stack register (problem 11 in the requirements).

Stack Input/Output:
[[x, y, z], Y, Z, T | L]-> XEQ Q ->[[cx, cy, cz], [x, y, z], Y, Z | L]
Where (x, y, z) is point p and (cx, cy, cz) is closest point in plane to p.


N : Plane's normalized normal vector. Populated by the P program.
O : Plane's distance to origo (0, 0, 0). Populated by the P program.
Q001 LBL Q
Q002 eq REGX-(REGXxN+O)xN
Q003 RTN

Terms of use.

Mnemonic: Sorry, run out :-(

Unless the input is a point in the plane (if this is the case the vectors in Y and X stack register are the same after execution) the line defined by the point in Y stack register and the point in X stack register defines the perpendicular line from point now in the Y stack register onto the plane entered using the program P. May be used as input to the L program or M program.

No comments: