(50g) interception of two lines
10-25-2015, 05:10 PM
Post: #1
 peacecalc Member Posts: 176 Joined: Dec 2013
(50g) interception of two lines
Hello folks,

This program calculates the resultes of interception and give them back with exact values. The program uses the command LINSOLVE that is the fastes way because the numerical MSLV needs a lot of more time even for linear systems. And if there is no solution (parallel or skew lines) it will take a lot of more time to come to an end.

But the LINSOLVE only works correct in exact mode. So if you have an input with real vector componets you have them to convert into exact ones (the program does it automatically).

The program recognizes the 2D or 3D input by itself.

A line (2D or 3D) can be represented in the form:

$\vec{x} = \vec{t} + \alpha\cdot\vec{r}$.

ti an ri are 2D or 3D vectors

stack 4: ta
stack 3: ra
stack 2: tb
stack 1: rb

Here we go:
Code:
 %%HP: T(3)A(R)F(,); \<< 1, 4,                                                          @@convert the vectors in       START \->Q\pi 4, ROLL                                        @@vectors with exact components       NEXT                                                         @@\->Q doesn't work on vectors, so you have to use \->Q\pi       \-> TA RA TB RB       \<< TA TB - 'A' RA * 'B' RB * - +                            @@ preparing input for LINSOLVE              OBJ\-> OBJ\-> DROP \-> N                  \<< N                   IF 2, ==                   THEN 0 = SWAP 0 = SWAP N \->ARRY              @@input for 2D vector equation                   ELSE 0 = ROT 0 = ROT 0 = ROT N \->ARRY        @@input for 3D vector equation                   END [ 'A' 'B' ]                               @@output variables                   LINSOLVE                    ROT DROP                    SWAP DROP                    DUP SIZE OBJ\-> DROP \-> LV NL                @@preparing output from LINSOLVE for analysing                   \<< LV NL GET                         EXLR  \-> LEQ REQ                                             \<<  IF LEQ 'B' SAME                               THEN TB RB REQ * +                                        REQ LV NL 1, - GET                                        EXLR SWAP DROP SWAP 3, \->LIST 1, @@ output for interception point                               ELSE                                       IF LEQ 'A' SAME                                       THEN TA 'A' RA * + 2,             @@ output for identical lines                                       ELSE { } 0,                       @@ output for parallel or skew lines                                       END                               END                        \>>                   \>>              \>>       \>> \>>

output has for all three cases the same two stack form:

stack 2: {[x y (z)] A B} (for interception point for 2D or 3D, coordinates of the point and parameter values for the line representations )
stack 1: 1,
or
stack 2: 'ta + A*ra' (for identical lines)
stack 1: 2,
or
stack 2: {} (for no interception)
stack 1: 0
 « Next Oldest | Next Newest »

 Messages In This Thread (50g) interception of two lines - peacecalc - 10-25-2015 05:10 PM

User(s) browsing this thread: 1 Guest(s)