Post Reply 
(20S and 21S) Triangle Program
06-03-2017, 06:29 PM (This post was last modified: 06-15-2017 01:17 PM by Gene.)
Post: #1
(20S and 21S) Triangle Program
Given three Cartesian coordinates, through points (R1, R4), (R2, R5), and (R3, R6), this program calculates:

1. The lengths of each side, represented by R7, R8, and R9.

2. The angle between lines connected by (R1, R4)-(R2, R5) and (R2, R5)-(R3, R6). The angle is stored in R0.

3. The area of the triangle. This is the final results shown.

[see diagram below]

The keystrokes for the HP 20S and HP 21S in this program are the same. Store the coordinates in variables R1 through R6, then press XEQ A.

HP 20S and HP 21S Program: Triangle Program
Code:

STEP    CODE    KEY
01    61, 41, A    LBL A
02    22, 1    RCL 1
03    65    -
04    22, 2    RCL 2
05    31    INPUT
06    22, 4    RCL 4
07    65    -
08    22, 5    RCL 5
09    51, 21    >P
10    51, 31    SWAP
12    26    R/S
13    71    [ C ] Clear
14    22, 2    RCL 2
15    65    -
16    22, 3    RCL 3
17    31    INPUT
18    22, 5    RCL 5
19    65    -
20    22, 6    RCL 6
21    51, 21    >P
22    51, 31    SWAP
23    21, 8    STO 8
24    26    R/S
25    71     [ C ] (Clear)
26    22, 1    RCL 1
27    65    -
28    22, 3    RCL 3
29    31    INPUT
30    22, 4    RCL 4
31    65    -
32    22, 6    RCL 6
33    51, 21    >P
34    51, 31    SWAP
35    21, 9    STO 9
36    26    R/S
37    71    [ C ] Clear
38    22, 8    RCL 8
39    51, 11    x^2
40    75    +
41    22, 9    RCL 9
42    51, 11    x^2
43    65    -
44    22, 7    RCL 7
45    51, 11    x^2
46    74    =
47    45    ÷ 
48    2    2
49    45    ÷
50    22, 8    RCL 8
51    45    ÷ 
52    22, 9    RCL 9
53    74    =
54    51, 24    ACOS
55    21, 0    STO 0
56    26    R/S
57    23    SIN
58    55    *
59    22, 7    RCL 7
60    55    *
61    22, 8    RCL 8
62    45    ÷
63    2    2
64    74    =
65    61, 26    RTN

Example:
Inputs:
(R1, R4) = (4, 8)
(R2, R5) = (2, 3)
(R3, R6) = (3, 10)

Outputs:
R7 = 5.3852
R8 = 7.0711
R9 = 2.2361
R0 = 34.6952°
Area = 10.8374


Attached File(s) Thumbnail(s)
   
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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