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:

Reads:

A : Line's first defining point. Populated by the L program.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.

R001 LBL RComments:

R002 XEQ U001

R003 RCL N

R004 RCL B

R005 RCL A

R006 -

ROO7 x

R008 ABS

R009 1E-6

R010 X>Y?

R011 GTO M041

R012 RDN

R013 LASTX

R014 eq -(AxN+0)/REGX

R015 XEQ U070

R016 RTN

Terms of use.

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!

## No comments:

Post a Comment