## Wednesday, October 3, 2007

### HP-35s Euclid Implementation - XI : Line Plane Intersection

The point of intersection between a line and a plane (problem 12 in the requirements) is given by the parameter (to it's parametric equation) t=-(ax0+by0+cz0+d)/n*(p1-p0) (* is here the dot product) where p0=(x0, y0, z0) and p1 are the two points defining the line.

The following program finds the intersection between the 3D line defined using the L program (p0 stored in variable A and p1 stored in variable B) and the plane defined using the P program ([a, b, c] stored in variable N and d stored in variable O).

Stack Input/Output:
`No input on stack-> XEQ R ->[t, X, Y, Z | L]`
Where t is the parameter defining intersection point using line l's parametric equation.

If n*(p1-p0)=0 then the line and the plane are paralell and there is no intersection point. In that case the message "PARALELL" is displayed shortly, stack and LASTX registers are then left unchanged.

Variables:

`A : Line's first defining point. Populated by the L program.B : Line's second defining point. Populated by the L program.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.`
Program:
`R001 LBL RR002 XEQ U001R003 RCL NR004 RCL BR005 RCL AR006 -ROO7 xR008 ABSR009 1E-6R010 X>Y?R011 GTO M041R012 RDNR013 LASTXR014 eq -(AxN+0)/REGXR015 XEQ U070R016 RTN`

Mnemonic: None.

Again when the result is a point on a line we produce the parameter giving the point, not the coordinates. So for example one learns that the line segment A, B intersect the plane if result is in the range [0, 1]. To get the coordinates end user does XEQ E.

Uses the new subroutine U070 to raise the stack and preserve LASTX register content in the case there is a solution (line and plane not paralell).

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

Change history:

20071004:1835UTC : Fixed typo in line R011, was GTO M014!