**HP 48G: Stefanescu Horatiu: Intersection of the Diagonals of a Quadrilateral**

The following program, written by Stefanescu Horatiu, calculates the intersection point of the two diagonals of a quadrilateral (partulator in Romanian).

The program takes place in a directory PATRULATERDIAGONALE. In order to type in the program, you will need to create a directory by using the CRDIR command.

This program also works on the HP 49G series (48gii, 49G, 49g+) and the HP 50g.

**HP 48G Program PATRULATERDIAGONALE - Stefanescu Horatiu**

Note: You are going to notice how all the subroutines flow together, as the first program calls the next program. You will need to enter and store all the programs for the entire routine to work correctly.

On a personal note, I like how the text is spelled out one letter at time. Hoartiu accomplishes this by using a FOR-NEXT structure which includes the commands 1 I SUB 1 DISP. (with I as the counter variable).

The text of the program is in Romanian.

The program is presented here with permission from the author, with full credit going to Stefanescu Horatiu. I thank Horatiu in allowing me to feature his work on my blog.

STARTDIAGONALE:

<< CLEAR CLLCD 1 110 FOR I

"ACEST PROGRAM CALCUL

EAZA COORDONATELE PUN

CTULUI DE INTERSECTIE

A DIAGONALELOR UNUI

PATRULATER OARECARE."

1 I SUB 1 DISP

NEXT 0 WAIT

INTRODUCERE >>

INTRODUCERE: (User input screen)

<< CLLCD

"COORDONATE PATRULATER"

{"Ax" "Ay" "Bx"

"By" "Cx" "Cy" "Dx"

"Dy" } { 2 4 } { }

{ } INFORM DROP

OBJ→ DROP 'DY' STO

'DX' STO 'CY' STO

'CX' STO 'BY' STO

'BX' STO 'AY' STO

'AX' STO CLLCD

EMURILE >>

EMURILE: (the start of the calculation routines)

<< 'CY-AY' →NUM 'M1' STO

'-AX*(CY-AY)' →NUM 'M2' STO

'CX-AX' →NUM 'M3' STO

'-AY*(CX-AX)' →NUM 'M4' STO

ENURILE >>

ENURILE:

<< 'BY-DY' →NUM 'N1' STO

'-DX*(BY-DY)' →NUM 'N2' STO

'BX-DX' →NUM 'N3' STO

'-DY*(BX-DX)' →NUM 'N4' STO

ESURILE >>

ESURILE:

<< 'N1-N3*M1/M3' →NUM 'S1' STO

'N3*(M2-M4)/M3+N4-N2' →NUM 'S2' STO

PURILE >>

PURILE:

<< 'S2/S1' →NUM 'PX' STO

'(PX*M1+M2-M4)/M3' →NUM 'PY' STO

REZULTATE >>

REZULTATE: (display the results)

<< CLLCD 1 59

FOR I

"Coordonate punct de

intersectie ale dia

gonalelor: P(x,y)"

1 I SUB 1 DISP NEXT 4 FIX

"P(" PX + →STR ";" +

→STR PY + →STR ")"

+ →STR 5 DISP 0 WAIT

STERG >>

STERG: (cleanup, purge working variables)

<< { AX AY BX BY CX

CY DX DY PX PY M1

M2 M3 M4 N1 N2 N3

N4 S1 S2 } PURGE

CLLCD CLEAR >>

**Instructions:**

Set your calculator the folder PATRULATERDIAGONALE. Run STARTDIAGONALE and enter the coordinates. The rest of the program runs automatically. Start with the left hand corner and go clockwise.

Note: I typed Horatiu's program on an HP 49G. In REZULTATE, for some reason I couldn't get the FIX 4 to take effect, even when I switched the calculator to Approximate mode. So in order to get both PX and PY on the screen, I added a carriage return character (↲, [right shift] [ 2 ]) after the semicolon. This creates a new line allowing both coordinates to be displayed.

**Example:**

Example 1: (Horatiu's example)

A: (ax, ay): (2, 10)

B: (bx, by): (11, 12)

C: (cx, cy): (13, 6)

D: (dx, dy): (1, 4)

P: (px, py): (6.46875, 8.375)

FIX 4: (6.4688, 8.3750)

Example 2: (my own example)

A: (ax, ay): (0, 8)

B: (bx, by): (5, 12)

C: (cx, cy): (7, 7)

D: (dx, dy): (2, 1)

P: (px, py): (3.72649999999, 7.4625)

FIX 4: (3.7265, 7.4625)

Source:

Horatiu, Stefanescu "Calculul Coordonatelor Punctului de Intersectie A Diagonalelor Unui Partulater Oarecare" 2018.

Eddie

All original content copyright, © 2011-2018. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. Please contact the author if you have questions.

thank you https://calculator.cool/

ReplyDelete