How to resolve the algorithm Find the intersection of two lines step by step in the Ring programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Find the intersection of two lines step by step in the Ring programming language
Table of Contents
Problem Statement
Find the point of intersection of two lines in 2D.
The 1st line passes though (4,0) and (6,10) . The 2nd line passes though (0,3) and (10,7) .
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Find the intersection of two lines step by step in the Ring programming language
Source code in the ring programming language
# Project : Find the intersection of two lines
xa=4
ya=0
xb=6
yb=10
xc=0
yc=3
xd=10
yd=7
see "the two lines are:" + nl
see "yab=" + (ya-xa*((yb-ya)/(xb-xa))) + "+x*" + ((yb-ya)/(xb-xa)) + nl
see "ycd=" + (yc-xc*((yd-yc)/(xd-xc))) + "+x*" + ((yd-yc)/(xd-xc)) + nl
x=((yc-xc*((yd-yc)/(xd-xc)))-(ya-xa*((yb-ya)/(xb-xa))))/(((yb-ya)/(xb-xa))-((yd-yc)/(xd-xc)))
see "x=" + x + nl
y=ya-xa*((yb-ya)/(xb-xa))+x*((yb-ya)/(xb-xa))
see "yab=" + y + nl
see "ycd=" + (yc-xc*((yd-yc)/(xd-xc))+x*((yd-yc)/(xd-xc))) + nl
see "intersection: " + x + "," + y + nl
You may also check:How to resolve the algorithm Luhn test of credit card numbers step by step in the Crystal programming language
You may also check:How to resolve the algorithm Copy stdin to stdout step by step in the Python programming language
You may also check:How to resolve the algorithm Statistics/Basic step by step in the REXX programming language
You may also check:How to resolve the algorithm Address of a variable step by step in the NewLISP programming language
You may also check:How to resolve the algorithm Bitmap/Bézier curves/Cubic step by step in the TI-89 BASIC programming language