## Wednesday, September 26, 2007

### HP-35s Euclid Implementation - VII : Defining a plane

Time to start working with the plane: First a data entry program to define a plane given a point in the plane and a vector normal to it.

This program is similar to the L program in that it computes a hyperplane's (now of 3D space) implicit equation (problem 9A of the specification).

The program accepts the defining point in the Y stack register and a vector normal to the plane in X stack register.

It stores the point that defines the plane in variable P (mnemonic: plane's point), the normalized normal vector in variable N (mnemonic: plane's normal) and the constant d of the plane's implicit equation ax+by+cz+d=0 in variable O (mnemonic: distance from origo to plane, true since equation normailized; see comments section). Since [a, b, c] is the plane's normal (stored in variable N) the computation of d=-(N*P) (* is here the dot product) is what is to be done to compute the plane's implicit equation.

Stack Input/Output:
`[[nx, ny, nz], [x, y, z], Z, T | L]-> XEQ P->[d, [a, b, c], [x, y, z], Z | [nx, ny, nz]]`
Where [nx, ny, nz] is a vector normal to the plane and (x, y, z) is a point in the plane. Output is the constants of the normalized implicit plane equation ax+by+cz+d=0. Content of Y stack register [a, b, c] is [nx, ny, nz] normalized, orginal vector can be found in LASTX register.

Variables:

Writes:
`N : Plane's normalized normal vector.O : Signed distance to origo (0, 0, 0).P : Defining point in plane.`
Program:
`POO1 LBL PP002 XEQ X004P003 STO NP004 X<>YP005 STO PP006 eq -(PxN)P007 STO OP008 RDNP009 X<>YP010 R^P011 RTN`