TUTORIAL 4: Further programming
VECTORS

The HP48 handles both 2D and 3D vectors to define lines or points in space. This tutorial only deals with 2D vectors as the principles and commands are similar for 3D.
A Vector in surveying terms in two ways:

In RECT mode as [ DeltaN DeltaE ]
In CYLIN (POLAR) mode as [ Distance Bearing ]

To build a RECT vector from the stack:

Enter the difference in Northings onto the stack
Enter the difference in Eastings onto the stack
Press [MTH] |VECTR| [NXT] |RECT| to ensure the HP48 is in RECT mode
Press [NXT] |->V2| To convert the 2 levels of the stack into a RECT vector

To build a CYLIN (POLAR) vector from the stack:

Enter the distance onto the stack
Enter the bearing onto the stack
Press [MTH] |VECTR| [NXT] |CYLIN| to ensure the HP48 is in CYLIN mode
Press [NXT] |->V2| to convert the 2 levels of the stack into a CYLIN vector

Program commands to convert from Rectangular to Polar (Degrees)

Difference in Northings is on level 2 of the stack
Difference in Eastings is on level 1 of the stack
<< DEG RECT \->V2 CYLIN V\-> RECT >>
Distance is on level 2 of the stack
Bearing is on level 1 of the stack

Program commands to convert from Polar to Rectangular (Degrees)

Distance is on level 2 of the stack
Bearing is on level 1 of the stack
<< DEG CYLIN \->V2 RECT V\-> >>
Difference in Northings is on level 2 of the stack
Difference in Eastings is on level 1 of the stack

MATRIX OPERATIONS

A Matrix is delimited as follows:

[ [ row 1 ]
[ row 2 ]
.
.
[ row n ] ]

To assemble a matrix by rows from a series of vectors

Enter each vector (representing rows of the matrix) onto the stack in the order you want them to appear in the matrix. Enter the number of rows of the matrix onto level one. Press [MTH] |MATR| |ROW| |ROW->|

To assemble a matrix by columns from a series of vectors

Enter each vector (representing columns of the matrix) onto the stack in the order you want them to appear in the matrix. Enter the number of columns of the matrix onto level one. Press [MTH] |MATR| |COL| |COL->|

To assemble a diagonal matrix (zeros elsewhere)

Enter the vector containing the diagonal elements. Enter the dimension of the matrix (No. of rows/columns). Press [MTH] |MATR| [NXT] |DIAG->|

To assemble an matrix from elements

Enter all the elements of the matrix onto the stack in row order (like a book). Enter a list of { rows columns } onto level one of the stack to define the matrix. Press [PRG] |TYPE| |->ARR|

Useful matrix and vector commands

DET returns the determinant of a square matrix on level one
INV returns the inverse of a square matrix on level one
TRN transposes a matrix on level one
* + - all perform aritmetric operations on matrices

USING LISTS

A list is a series of objects within { } delimeters. Objects within the list must be separated by a space. Many HP48 commands can be formed on a list of objects, the result being returned also a list. This saves the need for unnecessary code, memory wastage and significantly improves program speed.

To build a list from the stack

Enter the elements of the list onto the stack. Enter the number of elements to be included in the list onto level one of the stack. Press [PRG] |LIST| |->LIST|

To add an element to a list

Enter the list onto the stack. Enter the new element and press +

List processing commands

Many HP48 commands can be performed on each element within a list by entering the list onto the stack, executing the command. The resulting list is the command performed on each element of the list.

To add two lists

Enter both lists and execute the ADD command.

To sum all elements in a list

Enter the list onto the stack. Execute SigmaLIST. All elements in the list are added together.

To reverse a list

Enter the list onto the stack, execute REVLIST. The sequence of elements in the list is reversed.

Examples of list processing:
To convert all the vectors on a stack from polar to rectangular, to find the misclose bearing and distance.

There are say five polar vectors on the stack, nothing else. The calculator is in CYLIN mode
<< DEPTH 1 - ->LIST
RECT SigmaLIST CYLIN >>

Another example: To work out the proportional misclose of a similar list above.

There are say five polar vectors on the stack, nothing else. The calculator is in CYLIN mode
<< RECT DEPTH 1 - ->LIST DUP
ABS SigmaLIST SWAP SigmaLIST ABS / >>


Go to next tutorial

Return to
Tutorial page| Programming tips| Quickclose Homepage|

QUICKCLOSE
ABN 68 801 812 834
PO Box 1035 LEICHHARDT NSW 2040 AUSTRALIA
Tel/Fax +61 +2 9550 0010
EMAIL : quickclose@quickclose.com.au

Created with EditPad
Last Update: 18th March 2001
Richard Stanaway