How to resolve the algorithm Circles of given radius through two points step by step in the Oforth programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Circles of given radius through two points step by step in the Oforth programming language
Table of Contents
Problem Statement
Given two points on a plane and a radius, usually two circles of given radius can be drawn through the points.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Circles of given radius through two points step by step in the Oforth programming language
Source code in the oforth programming language
: circleCenter(x1, y1, x2, y2, r)
| d xmid ymid r1 md |
x2 x1 - sq y2 y1 - sq + sqrt -> d
x1 x2 + 2 / -> xmid
y1 y2 + 2 / -> ymid
2 r * -> r1
d 0.0 == ifTrue: [ "Infinite number of circles" . return ]
d r1 == ifTrue: [ System.Out "One circle: (" << xmid << ", " << ymid << ")" << cr return ]
d r1 > ifTrue: [ "No circle" . return ]
r sq d 2 / sq - sqrt ->md
System.Out "C1 : (" << xmid y1 y2 - md * d / + << ", " << ymid x2 x1 - md * d / + << ")" << cr
System.Out "C2 : (" << xmid y1 y2 - md * d / - << ", " << ymid x2 x1 - md * d / - << ")" << cr
;
You may also check:How to resolve the algorithm Guess the number/With feedback step by step in the Befunge programming language
You may also check:How to resolve the algorithm Higher-order functions step by step in the J programming language
You may also check:How to resolve the algorithm Non-decimal radices/Input step by step in the Ada programming language
You may also check:How to resolve the algorithm Multiplication tables step by step in the Maple programming language
You may also check:How to resolve the algorithm Filter step by step in the PL/I programming language