Line-Line Intersection/Grid Points

Description

Origin: David Stedman in "HP-67/HP-97 Users' Library Solutions - Geometry", pp. 26-32

This program will calculate the point of intersection of two lines and the Cartesian coordinates of points in other systems.

For both problems, the user specifies the angle from horizontal to lines in the problem. Slope will be converted to angle by the relation θ = tan-1 (slope). Given two points (x1, y1) and (x2, y2) on the line, the angle is
          y2 − y1
θ = tan-1 ———————
          x2 − x1

Line-Line Intersection:

  (x,y) = Coordinates
(x1,y1) = Coordinates of point on line one
(x2,y2) = Coordinates of point on line two
     θ1 = Angle from horizontal to line one
     θ2 = Angle from horizontal to line two


Grid Points:

  (x0,y0) = Coordinates of 0, 0 grid point
    h1,h2 = Grid system unit vectors
       θ1 = Angle to h1 unit vector
       θ2 = Angle to h2 unit vector
(xij,yij) = Coordinates of i,j grid point

Equations:
Line-Line Intersection

Image for line-line intersection

    x1 tan θ1 − x2 tan θ2 − y1
x = ——————————————————————————
          tan θ1 − tan θ2

y = y1 + (x − x1) tan θ1


Grid Points:

Image for grid points

xij = x0 + jΔx1 + iΔx2
yij = y0 + jΔy1 + iΔy2
Δx1 = h1 cos θ1
Δy1 = h1 sin θ1
Δx2 = h2 cos θ2
Δy2 = h2 sin θ2


Instructions:

For line-line intersection (no vertical lines):

For line-line intersection (one vertical line):

For grid points:

  1. For additional points on the grid repeat the 3rd step.
For a new case go to the first step of 1,3 or 4

Sample Problems:

Example 1: Find the point of intersection of two lines passing through (10,20), (40,30) and (-10,30) (50,10).

10 ENTER 20 ENTER 40 ENTER 30 GSB 1

10 CHS 30 ENTER 50 ENTER 10 GSB 2 → 15.00 , 21.67

Example 2: Find the intersection of a line through (0,0) with slope 2.8 and the line with equation x = 4.5.

4.5 ENTER 0 ENTER 0 ENTER 2.8 GSB 5 → 12.60

Example 3: For a grid with its origin at (1,1) and vectors 2 and 3 units long at 30 and 90 degrees, respectively, find the cartesian coordinates for the following grid coordiantes: (0,0), (1,0), (2,0), (0,1), (0,2), (1,1), (1.5,3).

1 ENTER 1 ENTER 2 ENTER 3 C 30 ENTER 90 D 0 ENTER 0 E → 1.00 , 1.00

1 ENTER 0 E → 1.00 , 4.00
2 ENTER 0 E → 7.00 , 7.00
0 ENTER 1 E → 2.73 , 2.00
0 ENTER 2 E → 4.46 , 3.00
1 ENTER 1 E → 2.73 , 5.00
1.5 ENTER 3 E → 6.20 , 8.50

Program Resources

Labels

Name Description Name Description
 A Line 1: [x] x₁ y₁ θ₁  1 x₁ y₁ xⱼ yⱼ
 B Line 2: x₂ y₂ θ₂  2 x₂ y₂ x₂´ y₂´
 C Grid: x₀ y₀ h₁ h₂  3 x₁ y₁ slope₁
 D Grid: θ₁ θ₂  4 x₂ y₂ slope₂
 E Grid: i j xᵢⱼ yᵢⱼ  5 [x] x₁ y₁ slope₁

Storage Registers

Name Description Name Description
 1 x₁, x₀  7 h₁
 2 y₁, Δx₁  8 h₂
 3 tan θ₁, Δx₂ .1
 4 tan θ₂, y₀ .2
 5 Δy₁ .5
 6 Δy₂

Flags

Number Description
2

Program

Line Display Key Sequence Line Display Key Sequence Line Display Key Sequence
000 057 25 TAN 114 45 1 RCL 1
001 42,21, 1 f LBL 1 058 44 4 STO 4 115 40 +
002 42 34 f REG 059 34 x↔y 116 34 x↔y
003 44 4 STO 4 060 33 R⬇ 117 44 7 STO 7
004 33 R⬇ 061 20 × 118 45 3 RCL 3
005 44 3 STO 3 062 43 33 g R⬆ 119 20 ×
006 33 R⬇ 063 30 120 40 +
007 44 2 STO 2 064 45 2 RCL 2 121 45 8 RCL 8
008 33 R⬇ 065 40 + 122 45 5 RCL 5
009 44 1 STO 1 066 45 1 RCL 1 123 20 ×
010 45 4 RCL 4 067 30 124 45 4 RCL 4
011 45 2 RCL 2 068 45 4 RCL 4 125 40 +
012 30 069 45 3 RCL 3 126 45 7 RCL 7
013 45 3 RCL 3 070 30 127 45 6 RCL 6
014 45 1 RCL 1 071 10 ÷ 128 20 ×
015 30 072 45 4 RCL 4 129 40 +
016 10 ÷ 073 45 1 RCL 1 130 43 32 g RTN
017 43 25 g TAN⁻¹ 074 30 131 42,21, 3 f LBL 3
018 44 5 STO 5 075 45 3 RCL 3 132 42 34 f REG
019 45 1 RCL 1 076 20 × 133 44 3 STO 3
020 44 .1 STO . 1 077 45 2 RCL 2 134 33 R⬇
021 45 2 RCL 2 078 40 + 135 44 2 STO 2
022 44 .2 STO . 2 079 31 R/S 136 33 R⬇
023 45 5 RCL 5 080 42,21,13 f LBL C 137 44 1 STO 1
024 44 .5 STO . 5 081 44 8 STO 8 138 45 3 RCL 3
025 42,21,11 f LBL A 082 33 R⬇ 139 43 25 g TAN⁻¹
026 25 TAN 083 44 7 STO 7 140 44 4 STO 4
027 44 3 STO 3 084 33 R⬇ 141 45 1 RCL 1
028 33 R⬇ 085 44 4 STO 4 142 45 2 RCL 2
029 44 2 STO 2 086 33 R⬇ 143 45 4 RCL 4
030 33 R⬇ 087 44 1 STO 1 144 43, 6, 2 g F? 2
031 44 1 STO 1 088 31 R/S 145 22 12 GTO B
032 30 089 42,21,14 f LBL D 146 22 11 GTO A
033 20 × 090 1 1 147 43 32 g RTN
034 40 + 091 42 1 f → R 148 42,21, 4 f LBL 4
035 31 R/S 092 45 8 RCL 8 149 43, 4, 2 g SF 2
036 42,21, 2 f LBL 2 093 20 × 150 22 3 GTO 3
037 42 34 f REG 094 44 3 STO 3 151 43 32 g RTN
038 44 4 STO 4 095 33 R⬇ 152 42,21, 5 f LBL 5
039 33 R⬇ 096 45 8 RCL 8 153 42 34 f REG
040 44 3 STO 3 097 20 × 154 44 4 STO 4
041 33 R⬇ 098 44 6 STO 6 155 33 R⬇
042 44 2 STO 2 099 33 R⬇ 156 44 3 STO 3
043 44 1 STO 1 100 1 1 157 33 R⬇
044 45 4 RCL 4 101 42 1 f → R 158 44 2 STO 2
045 45 2 RCL 2 102 45 7 RCL 7 159 33 R⬇
046 30 103 20 × 160 44 1 STO 1
047 45 3 RCL 3 104 44 2 STO 2 161 45 4 RCL 4
048 45 1 RCL 1 105 33 R⬇ 162 43 25 g TAN⁻¹
049 30 106 45 7 RCL 7 163 44 5 STO 5
050 10 ÷ 107 20 × 164 45 1 RCL 1
051 43 25 g TAN⁻¹ 108 44 5 STO 5 165 45 2 RCL 2
052 44 5 STO 5 109 31 R/S 166 45 3 RCL 3
053 45 1 RCL 1 110 42,21,15 f LBL E 167 45 5 RCL 5
054 45 2 RCL 2 111 44 8 STO 8 168 22 11 GTO A
055 45 3 RCL 3 112 45 2 RCL 2 169 43 32 g RTN
056 42,21,12 f LBL B 113 20 ×