## Thursday, October 11, 2007

### HP-35s Euclid Implementation - XII : Plane Plane Intersection

The intersection between two non paralell planes is a line (problem 13 of the requirements).

The program here computes two points that defines the intersection line between the plane defined by the P program and a second plane given as input to this program.

Stack Input/Output:
`[[nx, ny, nz], [px, py, pz], Z, T | L]-> XEQ V ->[[x1, y1, z1], [x0, y0, z0], [nx, ny, nz], [px, py, pz] | L]`
The input of the second plane is similar to defining the first plane using the P program: [nx, ny, nz] in X stack register is a vector normal to the second plane and (px, py, pz) in Y stack register is a point in the second plane. The result in the case the planes are not paralell is two points defining the line: (x0, y0, z0) and (x1, y1, z1).

In the case the planes are paralell the message "PARALELL" is displayed shortly, stack and LASTX registers are then left unchanged.

Variables:

Writes:
`R : Normalized normal vector.S : Distance from origo (0,0,0) to plane.T : Defining point in the plane.Z : Scratch data.`
Program:
`V001 LBL VV002 XEQ U001V003 XEQ X004V004 STO RV005 X<>YV006 STO TV007 X<>YV008 xV009 +/-V010 STO SV011 RCL NV012 LASTXV013 XEQ X001V014 STO ZV015 ABSV016 1E-6V017 X>Y?V018 GTO M041V019 LASTXV020 XEQ X025V021 1V022 X=Y?V023 GTO V032V024 RDNV025 2V026 X=Y?V027 GTO V036V028 eq (Sx([0,1,0]xN)-Ox([0,1,0]xR))/([0,0,1]xZ)V029 eq (Ox([1,0,0]xR)-Sx([1,0,0]xN))/([0,0,1]xZ)V030 0V031 GTO VO39V032 0V033 eq (Sx([0,0,1]xN)-Ox([0,0,1]xR))/([1,0,0]xZ)V034 eq (Ox([0,1,0]xR)-Sx([0,1,0]xN))/([1,0,0]xZ)V035 GTO V039V036 eq (Ox([0,0,1]xR)-Sx([0,0,1]xN))/([0,1,0]xZ)V037 0V038 eq (Sx([1,0,0]xN)-Ox([1,0,0]xR))/([0,1,0]xZ)V039 eq [REGZ,REGY,REGX]V040 ENTERV041 ENTERV042 RCL+ ZV043 XEQ U079V044 RTN`

Mnemonic: None.

The program stores the normalized implicit equation for the second plane and it's defining point in the calculator the same way as the P program does for the first plane: The normalized normal vector is stored in variable R, distance to origo in variable S and defining point in variable T. Mnemonics for these are that the keys associated with these variables are below and to the left of the keys assigned to the variables N, O and P where the same values are stored for the plane defined using the program P. This makes the relation between the P program and V program similar to the relation between the L program and the M program.

This program needs to compute and store the cross product of the two plane's normal vector: If this vector is of zero length the planes are paralell else it is a directional vector for the intersection line. This vector is stored in the Z variable.

This shares the show "PARALELL" message and stack restore code with the M program in the no solution case.

Change history:

20071013:1415UTC : This program was implemented before the X025 routine that finds the component of a 3D vector with largest absolute value. This program did that inline, now gone back and modified this program to use X025.