Post Reply 
(42S) Determine Circle From Three Given Points
07-16-2018, 07:19 AM (This post was last modified: 07-16-2018 11:55 AM by Dieter.)
Post: #5
RE: (42S) Determine Circle From Three Given Points
(07-16-2018 01:19 AM)gerry_in_polo Wrote:  Another observation: your program is 79 lines long, mine is 87, not really a significant difference ...

Your program can even be shorter by using RCL-arithmetic.
On the other hand my version has a quite elaborate output routine. Line 65 ff. can be replaced with a simple

Code:
65 VIEW "XC"
66 STOP
67 VIEW "YC"
68 STOP
69 VIEW "R"

Then take a look at the byte count. With the above simplification it's down to 149 Bytes.

(07-16-2018 01:19 AM)gerry_in_polo Wrote:  ...although a different approach is always worth knowing.

Yes, that's exactly why I posted it. This is just another way of solving the same problem. Isn't this what forums are all about?
But let me explain why I chose this method:

The approach here is the general circle equation: (X–Xc)² + (Y–Yc)² = R². The program solves the resulting equation system for the three given points. There is one significant advantage of this method: it doesn't matter if two Y-values are the same. Try (0|2), (4|2) and (2|0) and the program correctly returns the center at (2|2) and a radius of 2. This will not work with the other approach where a division by (Y2–Y1) and (Y3–Y2) takes place.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (42S) Determine Circle From Three Given Points - Dieter - 07-16-2018 07:19 AM



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