Circles of given radius through two points: Difference between revisions

Content added Content deleted
m (syntax highlighting fixup automation)
m (Automated syntax highlighting fixup (second round - minor fixes))
Line 1: Line 1:
[[Category:Geometry]]
{{task}}
{{task}}
[[File:2 circles through 2 points.jpg|650px||right|2 circles with a given radius through 2 points in 2D space.]]
[[File:2 circles through 2 points.jpg|650px||right|2 circles with a given radius through 2 points in 2D space.]]
Line 30: Line 31:
*   [http://mathforum.org/library/drmath/view/53027.html Finding the Center of a Circle from 2 Points and Radius] from Math forum @ Drexel
*   [http://mathforum.org/library/drmath/view/53027.html Finding the Center of a Circle from 2 Points and Radius] from Math forum @ Drexel
<br><br>
<br><br>

=={{header|11l}}==
=={{header|11l}}==
{{trans|Python}}
{{trans|Python}}


<syntaxhighlight lang=11l>T Circle
<syntaxhighlight lang="11l">T Circle
Float x, y, r
Float x, y, r


Line 123: Line 123:
ERROR: radius of zero
ERROR: radius of zero
</pre>
</pre>

=={{header|Action!}}==
=={{header|Action!}}==
{{libheader|Action! Tool Kit}}
{{libheader|Action! Tool Kit}}
{{libheader|Action! Real Math}}
{{libheader|Action! Real Math}}
<syntaxhighlight lang=Action!>INCLUDE "H6:REALMATH.ACT"
<syntaxhighlight lang="action!">INCLUDE "H6:REALMATH.ACT"


PROC Circles(CHAR ARRAY sx1,sy1,sx2,sy2,sr)
PROC Circles(CHAR ARRAY sx1,sy1,sx2,sy2,sr)
Line 214: Line 213:
p1=(.1234 .9876) p2=(.1234 .9876) r=0 -> Radius is zero, no circles
p1=(.1234 .9876) p2=(.1234 .9876) r=0 -> Radius is zero, no circles
</pre>
</pre>

=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
Calculations based on the C solution.
Calculations based on the C solution.
<syntaxhighlight lang=algol68># represents a point #
<syntaxhighlight lang="algol68"># represents a point #
MODE POINT = STRUCT( REAL x, REAL y );
MODE POINT = STRUCT( REAL x, REAL y );
# returns TRUE if p1 is the same point as p2, FALSE otherwise #
# returns TRUE if p1 is the same point as p2, FALSE otherwise #
Line 332: Line 330:
One circle : radius: 0.0000 @( 0.1234, 0.9876)
One circle : radius: 0.0000 @( 0.1234, 0.9876)
</pre>
</pre>

=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
<syntaxhighlight lang=AutoHotkey>CircleCenter(x1, y1, x2, y2, r){
<syntaxhighlight lang="autohotkey">CircleCenter(x1, y1, x2, y2, r){
d := sqrt((x2-x1)**2 + (y2-y1)**2)
d := sqrt((x2-x1)**2 + (y2-y1)**2)
x3 := (x1+x2)/2 , y3 := (y1+y2)/2
x3 := (x1+x2)/2 , y3 := (y1+y2)/2
Line 351: Line 348:
return cx1 "," cy1 " & " cx2 "," cy2
return cx1 "," cy1 " & " cx2 "," cy2
}</syntaxhighlight>
}</syntaxhighlight>
Examples:<syntaxhighlight lang=AutoHotkey>data =
Examples:<syntaxhighlight lang="autohotkey">data =
(
(
0.1234 0.9876 0.8765 0.2345 2.0
0.1234 0.9876 0.8765 0.2345 2.0
Line 372: Line 369:
0.1234 0.9876 0.1234 0.9876 0.0 > No circles can be drawn, points are identical
0.1234 0.9876 0.1234 0.9876 0.0 > No circles can be drawn, points are identical
</pre>
</pre>

=={{header|AWK}}==
=={{header|AWK}}==
<syntaxhighlight lang=AWK>
<syntaxhighlight lang="awk">
# syntax: GAWK -f CIRCLES_OF_GIVEN_RADIUS_THROUGH_TWO_POINTS.AWK
# syntax: GAWK -f CIRCLES_OF_GIVEN_RADIUS_THROUGH_TWO_POINTS.AWK
# converted from PL/I
# converted from PL/I
Line 415: Line 411:
0.1234 0.9876 0.1234 0.9876 0.00 radius of zero gives no circles
0.1234 0.9876 0.1234 0.9876 0.00 radius of zero gives no circles
</pre>
</pre>


=={{header|BASIC256}}==
=={{header|BASIC256}}==
{{trans|Liberty BASIC}}
{{trans|Liberty BASIC}}
<syntaxhighlight lang=BASIC256>
<syntaxhighlight lang="basic256">
function twoCircles(x1, y1, x2, y2, radio)
function twoCircles(x1, y1, x2, y2, radio)
if x1 = x2 and y1 = y2 then #Si los puntos coinciden
if x1 = x2 and y1 = y2 then #Si los puntos coinciden
Line 468: Line 462:
end
end
</syntaxhighlight>
</syntaxhighlight>


=={{header|C}}==
=={{header|C}}==
<syntaxhighlight lang=C>#include<stdio.h>
<syntaxhighlight lang="c">#include<stdio.h>
#include<math.h>
#include<math.h>


Line 549: Line 541:
No circles can be drawn through (0.1234,0.9876)
No circles can be drawn through (0.1234,0.9876)
</pre>
</pre>

=={{header|C sharp|C#}}==
=={{header|C sharp|C#}}==
{{works with|C sharp|6}}
{{works with|C sharp|6}}
<syntaxhighlight lang=csharp>using System;
<syntaxhighlight lang="csharp">using System;
public class CirclesOfGivenRadiusThroughTwoPoints
public class CirclesOfGivenRadiusThroughTwoPoints
{
{
Line 636: Line 627:
Points (0.1234, 0.9876) and (0.1234, 0.9876) with radius 0:
Points (0.1234, 0.9876) and (0.1234, 0.9876) with radius 0:
(0.1234, 0.9876)</pre>
(0.1234, 0.9876)</pre>

=={{header|C++}}==
=={{header|C++}}==
{{works with|C++11}}
{{works with|C++11}}
<syntaxhighlight lang=cpp>
<syntaxhighlight lang="cpp">
#include <iostream>
#include <iostream>
#include <cmath>
#include <cmath>
Line 712: Line 702:
Only one solution: 0.1234 0.9876
Only one solution: 0.1234 0.9876
</pre>
</pre>

=={{header|D}}==
=={{header|D}}==
{{trans|Python}}
{{trans|Python}}
<syntaxhighlight lang=d>import std.stdio, std.typecons, std.math;
<syntaxhighlight lang="d">import std.stdio, std.typecons, std.math;


class ValueException : Exception {
class ValueException : Exception {
Line 810: Line 799:
{{libheader| System.Math}}
{{libheader| System.Math}}
{{Trans|C}}
{{Trans|C}}
<syntaxhighlight lang=Delphi>
<syntaxhighlight lang="delphi">
program Circles_of_given_radius_through_two_points;
program Circles_of_given_radius_through_two_points;


Line 901: Line 890:
readln;
readln;
end.</syntaxhighlight>
end.</syntaxhighlight>

=={{header|Elixir}}==
=={{header|Elixir}}==
{{trans|Ruby}}
{{trans|Ruby}}
<syntaxhighlight lang=elixir>defmodule RC do
<syntaxhighlight lang="elixir">defmodule RC do
def circle(p, p, r) when r>0.0 do
def circle(p, p, r) when r>0.0 do
raise ArgumentError, message: "Infinite number of circles, points coincide."
raise ArgumentError, message: "Infinite number of circles, points coincide."
Line 979: Line 967:
{0.1234, 0.9876, 0.0}
{0.1234, 0.9876, 0.0}
</pre>
</pre>

=={{header|ERRE}}==
=={{header|ERRE}}==
<syntaxhighlight lang=text>
<syntaxhighlight lang="text">
PROGRAM CIRCLES
PROGRAM CIRCLES


Line 1,034: Line 1,021:
END PROGRAM
END PROGRAM
</syntaxhighlight>
</syntaxhighlight>

=={{header|F Sharp|F#}}==
=={{header|F Sharp|F#}}==
<syntaxhighlight lang=fsharp>open System
<syntaxhighlight lang="fsharp">open System


let add (a:double, b:double) (x:double, y:double) = (a + x, b + y)
let add (a:double, b:double) (x:double, y:double) = (a + x, b + y)
Line 1,077: Line 1,063:
<null>
<null>
<null></pre>
<null></pre>

=={{header|Factor}}==
=={{header|Factor}}==
<syntaxhighlight lang=factor>USING: accessors combinators combinators.short-circuit
<syntaxhighlight lang="factor">USING: accessors combinators combinators.short-circuit
formatting io kernel literals locals math math.distances
formatting io kernel literals locals math math.distances
math.functions prettyprint sequences strings ;
math.functions prettyprint sequences strings ;
Line 1,191: Line 1,176:
one degenerate circle found at (0.1234, 0.9876).
one degenerate circle found at (0.1234, 0.9876).
</pre>
</pre>

=={{header|Fortran}}==
=={{header|Fortran}}==
<syntaxhighlight lang=fortran>
<syntaxhighlight lang="fortran">
! Implemented by Anant Dixit (Nov. 2014)
! Implemented by Anant Dixit (Nov. 2014)
! Transpose elements in find_center to obtain correct results. R.N. McLean (Dec 2017)
! Transpose elements in find_center to obtain correct results. R.N. McLean (Dec 2017)
Line 1,338: Line 1,322:
===Using complex numbers===
===Using complex numbers===
Fortran 66 made standard the availability of complex number arithmetic. This version however takes advantage of facilities offered in F90 so as to perform some array-based arithmetic, though the opportunities in this small routine are thin: two statements become one (look for CMPLX). More seriously, the MODULE facility allows the definition of an array SQUAWK which contains an explanatory text associated with each return code. The routine has a troublesome variety of possible odd conditions to report. An older approach would be to have a return message CHARACTER variable to present the remark, at the cost of filling up that variable with text every time. By returning an integer code, less effort is required, but there is no explication of the return codes. One could still have an array of messages (and prior to F90, array index counting started at one only, so no starting with -3 for errorish codes) but making that array available would require some sort of COMMON storage. The MODULE facility eases this problem.
Fortran 66 made standard the availability of complex number arithmetic. This version however takes advantage of facilities offered in F90 so as to perform some array-based arithmetic, though the opportunities in this small routine are thin: two statements become one (look for CMPLX). More seriously, the MODULE facility allows the definition of an array SQUAWK which contains an explanatory text associated with each return code. The routine has a troublesome variety of possible odd conditions to report. An older approach would be to have a return message CHARACTER variable to present the remark, at the cost of filling up that variable with text every time. By returning an integer code, less effort is required, but there is no explication of the return codes. One could still have an array of messages (and prior to F90, array index counting started at one only, so no starting with -3 for errorish codes) but making that array available would require some sort of COMMON storage. The MODULE facility eases this problem.
<syntaxhighlight lang=Fortran> MODULE GEOMETRY !Limited scope.
<syntaxhighlight lang="fortran"> MODULE GEOMETRY !Limited scope.
CHARACTER*(*) SQUAWK(-3:2) !Holds a schedule of complaints.
CHARACTER*(*) SQUAWK(-3:2) !Holds a schedule of complaints.
PARAMETER (SQUAWK = (/ !According to what might go wrong.
PARAMETER (SQUAWK = (/ !According to what might go wrong.
Line 1,433: Line 1,417:
One 'circle', centred on the co-incident points. R is zero!
One 'circle', centred on the co-incident points. R is zero!
</pre>
</pre>

=={{header|FreeBASIC}}==
=={{header|FreeBASIC}}==
<syntaxhighlight lang=freebasic>Type Point
<syntaxhighlight lang="freebasic">Type Point
As Double x,y
As Double x,y
Declare Property length As Double
Declare Property length As Double
Line 1,489: Line 1,472:
Points (0.1234,0.9876),(0.1234,0.9876), Rad 0
Points (0.1234,0.9876),(0.1234,0.9876), Rad 0
Points are the same</pre>
Points are the same</pre>

=={{header|Go}}==
=={{header|Go}}==
<syntaxhighlight lang=go>package main
<syntaxhighlight lang="go">package main


import (
import (
Line 1,596: Line 1,578:
Center: {0.1234 0.9876}
Center: {0.1234 0.9876}
</pre>
</pre>

=={{header|Groovy}}==
=={{header|Groovy}}==
{{trans|Java}}
{{trans|Java}}
<syntaxhighlight lang=groovy>class Circles {
<syntaxhighlight lang="groovy">class Circles {
private static class Point {
private static class Point {
private final double x, y
private final double x, y
Line 1,698: Line 1,679:
For points (0.1234, 0.9876) and (0.1234, 0.9876) with radius 0.000000
For points (0.1234, 0.9876) and (0.1234, 0.9876) with radius 0.000000
there is just one circle with center at (0.1234, 0.9876)</pre>
there is just one circle with center at (0.1234, 0.9876)</pre>

=={{header|Haskell}}==
=={{header|Haskell}}==
<syntaxhighlight lang=Haskell>add (a, b) (x, y) = (a + x, b + y)
<syntaxhighlight lang="haskell">add (a, b) (x, y) = (a + x, b + y)
sub (a, b) (x, y) = (a - x, b - y)
sub (a, b) (x, y) = (a - x, b - y)
magSqr (a, b) = (a ^^ 2) + (b ^^ 2)
magSqr (a, b) = (a ^^ 2) + (b ^^ 2)
Line 1,742: Line 1,722:
Nothing
Nothing
Nothing</pre>
Nothing</pre>

=={{header|Icon}} and {{header|Unicon}}==
=={{header|Icon}} and {{header|Unicon}}==
{{trans|AutoHotKey}}
{{trans|AutoHotKey}}
Works in both languages.
Works in both languages.
<syntaxhighlight lang=unicon>procedure main()
<syntaxhighlight lang="unicon">procedure main()
A := [ [0.1234, 0.9876, 0.8765, 0.2345, 2.0],
A := [ [0.1234, 0.9876, 0.8765, 0.2345, 2.0],
[0.0000, 2.0000, 0.0000, 0.0000, 1.0],
[0.0000, 2.0000, 0.0000, 0.0000, 1.0],
Line 1,779: Line 1,758:
->
->
</pre>
</pre>

=={{header|J}}==
=={{header|J}}==


2D computations are often easier using the complex plane.
2D computations are often easier using the complex plane.
<syntaxhighlight lang=J>average =: +/ % #
<syntaxhighlight lang="j">average =: +/ % #


circles =: verb define"1
circles =: verb define"1
Line 1,828: Line 1,806:
└───────────────────────────────┴────────────────────────────────────────────────────┘
└───────────────────────────────┴────────────────────────────────────────────────────┘
</syntaxhighlight>
</syntaxhighlight>

=={{header|Java}}==
=={{header|Java}}==
{{trans|Kotlin}}
{{trans|Kotlin}}
<syntaxhighlight lang=Java>import java.util.Objects;
<syntaxhighlight lang="java">import java.util.Objects;


public class Circles {
public class Circles {
Line 1,932: Line 1,909:
For points (0.1234, 0.9876) and (0.1234, 0.9876) with radius 0.000000
For points (0.1234, 0.9876) and (0.1234, 0.9876) with radius 0.000000
there is just one circle with center at (0.1234, 0.9876)</pre>
there is just one circle with center at (0.1234, 0.9876)</pre>

=={{header|JavaScript}}==
=={{header|JavaScript}}==


====ES6====
====ES6====


<syntaxhighlight lang=JavaScript>const hDist = (p1, p2) => Math.hypot(...p1.map((e, i) => e - p2[i])) / 2;
<syntaxhighlight lang="javascript">const hDist = (p1, p2) => Math.hypot(...p1.map((e, i) => e - p2[i])) / 2;
const pAng = (p1, p2) => Math.atan(p1.map((e, i) => e - p2[i]).reduce((p, c) => c / p, 1));
const pAng = (p1, p2) => Math.atan(p1.map((e, i) => e - p2[i]).reduce((p, c) => c / p, 1));
const solveF = (p, r) => t => [r*Math.cos(t) + p[0], r*Math.sin(t) + p[1]];
const solveF = (p, r) => t => [r*Math.cos(t) + p[0], r*Math.sin(t) + p[1]];
Line 1,982: Line 1,958:


Output:
Output:
<syntaxhighlight lang=JavaScript>
<syntaxhighlight lang="javascript">
Test: 0: p1: 0.1234,0.9876, p2: 0.8765,0.2345, r:2 Result: Circle at 1.8631118016581891,1.974211801658189 Circle at -0.863211801658189,-0.7521118016581889
Test: 0: p1: 0.1234,0.9876, p2: 0.8765,0.2345, r:2 Result: Circle at 1.8631118016581891,1.974211801658189 Circle at -0.863211801658189,-0.7521118016581889
Test: 1: p1: 0,2, p2: 0,0, r:1 Result: Points on diameter. Circle at: 0,1
Test: 1: p1: 0,2, p2: 0,0, r:1 Result: Points on diameter. Circle at: 0,1
Line 1,989: Line 1,965:
Test: 4: p1: 0.1234,0.9876, p2: 0.1234,0.9876, r:0 Result: Radius Zero
Test: 4: p1: 0.1234,0.9876, p2: 0.1234,0.9876, r:0 Result: Radius Zero
</syntaxhighlight>
</syntaxhighlight>

=={{header|jq}}==
=={{header|jq}}==
{{works with|jq|1.4}}
{{works with|jq|1.4}}
In this section, a point in the plane will be represented by its Cartesian co-ordinates expressed as a JSON array: [x,y].
In this section, a point in the plane will be represented by its Cartesian co-ordinates expressed as a JSON array: [x,y].
<syntaxhighlight lang=jq># circle_centers is defined here as a filter.
<syntaxhighlight lang="jq"># circle_centers is defined here as a filter.
# Input should be an array [x1, y1, x2, y2, r] giving the co-ordinates
# Input should be an array [x1, y1, x2, y2, r] giving the co-ordinates
# of the two points and a radius.
# of the two points and a radius.
Line 2,021: Line 1,996:
end;</syntaxhighlight>
end;</syntaxhighlight>
'''Examples''':
'''Examples''':
<syntaxhighlight lang=jq>(
<syntaxhighlight lang="jq">(
[0.1234, 0.9876, 0.8765, 0.2345, 2],
[0.1234, 0.9876, 0.8765, 0.2345, 2],
[0.0000, 2.0000, 0.0000, 0.0000, 1],
[0.0000, 2.0000, 0.0000, 0.0000, 1],
Line 2,031: Line 2,006:
{{out}}
{{out}}
<syntaxhighlight lang=sh>$ jq -n -c -r -f /Users/peter/jq/circle_centers.jq
<syntaxhighlight lang="sh">$ jq -n -c -r -f /Users/peter/jq/circle_centers.jq


[0.1234,0.9876,0.8765,0.2345,2] ───► [1.8631118016581893,1.974211801658189,-0.8632118016581896,-0.7521118016581892]
[0.1234,0.9876,0.8765,0.2345,2] ───► [1.8631118016581893,1.974211801658189,-0.8632118016581896,-0.7521118016581892]
Line 2,038: Line 2,013:
[0.1234,0.9876,0.8765,0.2345,0.5] ───► points are too far from each other
[0.1234,0.9876,0.8765,0.2345,0.5] ───► points are too far from each other
[0.1234,0.9876,0.1234,0.9876,0] ───► [0.1234,0.9876]</syntaxhighlight>
[0.1234,0.9876,0.1234,0.9876,0] ───► [0.1234,0.9876]</syntaxhighlight>

=={{header|Julia}}==
=={{header|Julia}}==
This solution uses the package [https://github.com/timholy/AffineTransforms.jl AffineTransforms.jl] to introduce a coordinate system (u, v) centered on the midpoint between the two points and rotated so that these points are on the u-axis. In this system, solving for the circles' centers is trivial. The two points are cast as complex numbers to aid in determining the location of the midpoint and rotation angle.
This solution uses the package [https://github.com/timholy/AffineTransforms.jl AffineTransforms.jl] to introduce a coordinate system (u, v) centered on the midpoint between the two points and rotated so that these points are on the u-axis. In this system, solving for the circles' centers is trivial. The two points are cast as complex numbers to aid in determining the location of the midpoint and rotation angle.


'''Types and Functions'''
'''Types and Functions'''
<syntaxhighlight lang=Julia>
<syntaxhighlight lang="julia">
immutable Point{T<:FloatingPoint}
immutable Point{T<:FloatingPoint}
x::T
x::T
Line 2,088: Line 2,062:


'''Main'''
'''Main'''
<syntaxhighlight lang=Julia>
<syntaxhighlight lang="julia">
tp = [Point(0.1234, 0.9876),
tp = [Point(0.1234, 0.9876),
Point(0.0000, 2.0000),
Point(0.0000, 2.0000),
Line 2,131: Line 2,105:
(0.1234, 0.9876), 0.0000
(0.1234, 0.9876), 0.0000
</pre>
</pre>

=={{header|Kotlin}}==
=={{header|Kotlin}}==
<syntaxhighlight lang=scala>// version 1.1.51
<syntaxhighlight lang="scala">// version 1.1.51


typealias IAE = IllegalArgumentException
typealias IAE = IllegalArgumentException
Line 2,215: Line 2,188:
there is just one circle with center at (0.1234, 0.9876)
there is just one circle with center at (0.1234, 0.9876)
</pre>
</pre>

=={{header|Lambdatalk}}==
=={{header|Lambdatalk}}==
<syntaxhighlight lang=scheme>
<syntaxhighlight lang="scheme">
input: OP1=(x1,y1), OP2=(x2,y2), r
input: OP1=(x1,y1), OP2=(x2,y2), r
output: OC = OH + HC
output: OC = OH + HC
Line 2,279: Line 2,251:
-> radius is zero
-> radius is zero
</syntaxhighlight>
</syntaxhighlight>

=={{header|Liberty BASIC}}==
=={{header|Liberty BASIC}}==
<syntaxhighlight lang=lb>
<syntaxhighlight lang="lb">
'[RC] Circles of given radius through two points
'[RC] Circles of given radius through two points
for i = 1 to 5
for i = 1 to 5
Line 2,330: Line 2,301:


Output:
Output:
<syntaxhighlight lang=text>
<syntaxhighlight lang="text">
1) 0.1234 0.9876 0.8765 0.2345 2
1) 0.1234 0.9876 0.8765 0.2345 2
(1.8631118,1.9742118)
(1.8631118,1.9742118)
Line 2,344: Line 2,315:
It will be a single point (0.1234,0.9876) of radius 0
It will be a single point (0.1234,0.9876) of radius 0
</syntaxhighlight>
</syntaxhighlight>

=={{header|Lua}}==
=={{header|Lua}}==
{{trans|C}}
{{trans|C}}
<syntaxhighlight lang=lua>function distance(p1, p2)
<syntaxhighlight lang="lua">function distance(p1, p2)
local dx = (p1.x-p2.x)
local dx = (p1.x-p2.x)
local dy = (p1.y-p2.y)
local dy = (p1.y-p2.y)
Line 2,414: Line 2,384:
Case 5
Case 5
No circles can be drawn through (0.1234, 0.9876)</pre>
No circles can be drawn through (0.1234, 0.9876)</pre>

=={{header|Maple}}==
=={{header|Maple}}==
<syntaxhighlight lang=maple>drawCircles := proc(x1, y1, x2, y2, r, $)
<syntaxhighlight lang="maple">drawCircles := proc(x1, y1, x2, y2, r, $)
local c1, c2, p1, p2;
local c1, c2, p1, p2;
use geometry in
use geometry in
Line 2,453: Line 2,422:
The circle is a point at [.1234, .9876].
The circle is a point at [.1234, .9876].
</pre>
</pre>

=={{header|Mathematica}}/{{header|Wolfram Language}}==
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<syntaxhighlight lang=Mathematica>Off[Solve::ratnz];
<syntaxhighlight lang="mathematica">Off[Solve::ratnz];
circs::invrad = "The radius is invalid.";
circs::invrad = "The radius is invalid.";
circs::equpts = "The given points (`1`, `2`) are equivalent.";
circs::equpts = "The given points (`1`, `2`) are equivalent.";
Line 2,480: Line 2,448:
circs[{.1234, .9876}, {.1234, .9876}, 0.]
circs[{.1234, .9876}, {.1234, .9876}, 0.]
circs::invrad: The radius is invalid.</pre>
circs::invrad: The radius is invalid.</pre>

=={{header|Maxima}}==
=={{header|Maxima}}==
<syntaxhighlight lang=Maxima>/* define helper function */
<syntaxhighlight lang="maxima">/* define helper function */
vabs(a):= sqrt(a.a);
vabs(a):= sqrt(a.a);
realp(e):=freeof(%i, e);
realp(e):=freeof(%i, e);
Line 2,526: Line 2,493:
apply('getsol, cons(sol, d[4]));</syntaxhighlight>
apply('getsol, cons(sol, d[4]));</syntaxhighlight>
{{out}}
{{out}}
<syntaxhighlight lang=text>apply('getsol, cons(sol, d[1]));
<syntaxhighlight lang="text">apply('getsol, cons(sol, d[1]));
two solutions
two solutions
(%o9) [[x0 = 1.86311180165819, y0 = 1.974211801658189],
(%o9) [[x0 = 1.86311180165819, y0 = 1.974211801658189],
Line 2,539: Line 2,506:
infinity many solutions
infinity many solutions
(%o12) infmany</syntaxhighlight>
(%o12) infmany</syntaxhighlight>

=={{header|МК-61/52}}==
=={{header|МК-61/52}}==
<syntaxhighlight lang=text>П0 С/П П1 С/П П2 С/П П3 С/П П4
<syntaxhighlight lang="text">П0 С/П П1 С/П П2 С/П П3 С/П П4
ИП2 ИП0 - x^2 ИП3 ИП1 - x^2 + КвКор П5
ИП2 ИП0 - x^2 ИП3 ИП1 - x^2 + КвКор П5
ИП0 ИП2 + 2 / П6 ИП1 ИП3 + 2 / П7
ИП0 ИП2 + 2 / П6 ИП1 ИП3 + 2 / П7
Line 2,562: Line 2,528:
"8.L" if the points are coincident; "8.-" if the points are opposite ends of a diameter of the circle, РY and РZ are coordinates of the center; "8.Г" if the points are farther away from each other than a diameter of a circle; else РX, РY and РZ, РT are coordinates of the circles centers.
"8.L" if the points are coincident; "8.-" if the points are opposite ends of a diameter of the circle, РY and РZ are coordinates of the center; "8.Г" if the points are farther away from each other than a diameter of a circle; else РX, РY and РZ, РT are coordinates of the circles centers.
</pre>
</pre>

=={{header|Modula-2}}==
=={{header|Modula-2}}==
<syntaxhighlight lang=modula2>MODULE Circles;
<syntaxhighlight lang="modula2">MODULE Circles;
FROM EXCEPTIONS IMPORT AllocateSource,ExceptionSource,GetMessage,RAISE;
FROM EXCEPTIONS IMPORT AllocateSource,ExceptionSource,GetMessage,RAISE;
FROM FormatString IMPORT FormatString;
FROM FormatString IMPORT FormatString;
Line 2,682: Line 2,647:
ReadChar
ReadChar
END Circles.</syntaxhighlight>
END Circles.</syntaxhighlight>

=={{header|Nim}}==
=={{header|Nim}}==
{{trans|Python}}
{{trans|Python}}
<syntaxhighlight lang=nim>import math
<syntaxhighlight lang="nim">import math


type
type
Line 2,770: Line 2,734:
You can construct the following circles:
You can construct the following circles:
ERROR: radius of zero</pre>
ERROR: radius of zero</pre>

=={{header|OCaml}}==
=={{header|OCaml}}==
Original version by [http://rosettacode.org/wiki/User:Vanyamil User:Vanyamil]
Original version by [http://rosettacode.org/wiki/User:Vanyamil User:Vanyamil]
<syntaxhighlight lang=OCaml>
<syntaxhighlight lang="ocaml">
(* Task : Circles of given radius through two points *)
(* Task : Circles of given radius through two points *)


Line 2,847: Line 2,810:
One solution: (0.123400, 0.987600)
One solution: (0.123400, 0.987600)
</pre>
</pre>

=={{header|Oforth}}==
=={{header|Oforth}}==


<syntaxhighlight lang=oforth>: circleCenter(x1, y1, x2, y2, r)
<syntaxhighlight lang="oforth">: circleCenter(x1, y1, x2, y2, r)
| d xmid ymid r1 md |
| d xmid ymid r1 md |
x2 x1 - sq y2 y1 - sq + sqrt -> d
x2 x1 - sq y2 y1 - sq + sqrt -> d
Line 2,886: Line 2,848:


</pre>
</pre>

=={{header|ooRexx}}==
=={{header|ooRexx}}==
{{trans|REXX}}
{{trans|REXX}}
<syntaxhighlight lang=oorexx>/*REXX pgm finds 2 circles with a specific radius given two (X,Y) points*/
<syntaxhighlight lang="oorexx">/*REXX pgm finds 2 circles with a specific radius given two (X,Y) points*/
a.=''
a.=''
a.1=0.1234 0.9876 0.8765 0.2345 2
a.1=0.1234 0.9876 0.8765 0.2345 2
Line 2,936: Line 2,897:
0.1234 0.9876 0.8765 0.2345 0.5 points are too far apart for the given radius
0.1234 0.9876 0.8765 0.2345 0.5 points are too far apart for the given radius
0.1234 0.9876 0.1234 0.9876 0.0 radius of zero gives no circles.</pre>
0.1234 0.9876 0.1234 0.9876 0.0 radius of zero gives no circles.</pre>

=={{header|PARI/GP}}==
=={{header|PARI/GP}}==
<syntaxhighlight lang=parigp>circ(a, b, r)={
<syntaxhighlight lang="parigp">circ(a, b, r)={
if(a==b, return("impossible"));
if(a==b, return("impossible"));
my(h=(b-a)/2,t=sqrt(r^2-abs(h)^2)/abs(h)*h);
my(h=(b-a)/2,t=sqrt(r^2-abs(h)^2)/abs(h)*h);
Line 2,954: Line 2,914:
%4 = [0.370374144 + 0.740625856*I, 0.629525856 + 0.481474144*I]
%4 = [0.370374144 + 0.740625856*I, 0.629525856 + 0.481474144*I]
%5 = "impossible"</pre>
%5 = "impossible"</pre>

=={{header|Perl}}==
=={{header|Perl}}==
{{trans|Python}}
{{trans|Python}}
<syntaxhighlight lang=perl>use strict;
<syntaxhighlight lang="perl">use strict;


sub circles {
sub circles {
Line 2,996: Line 2,955:
(0.1234, 0.9876) and (0.8765, 0.2345) with radius 0.5: Separation of points greater than diameter
(0.1234, 0.9876) and (0.8765, 0.2345) with radius 0.5: Separation of points greater than diameter
(0.1234, 0.9876) and (0.1234, 0.9876) with radius 0.0: Radius is zero</pre>
(0.1234, 0.9876) and (0.1234, 0.9876) with radius 0.0: Radius is zero</pre>

=={{header|Phix}}==
=={{header|Phix}}==
<!--<syntaxhighlight lang=Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">constant</span> <span style="color: #000000;">tests</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{{</span><span style="color: #000000;">0.1234</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">0.9876</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">0.8765</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">0.2345</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">2.0</span><span style="color: #0000FF;">},</span>
<span style="color: #008080;">constant</span> <span style="color: #000000;">tests</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{{</span><span style="color: #000000;">0.1234</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">0.9876</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">0.8765</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">0.2345</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">2.0</span><span style="color: #0000FF;">},</span>
Line 3,032: Line 2,990:
points {0.1234,0.9876}, {0.1234,0.9876} with radius 0.0 ==> same points/radius is zero
points {0.1234,0.9876}, {0.1234,0.9876} with radius 0.0 ==> same points/radius is zero
</pre>
</pre>

=={{header|PL/I}}==
=={{header|PL/I}}==
{{trans|REXX}}
{{trans|REXX}}
<syntaxhighlight lang=PL/I>twoci: Proc Options(main);
<syntaxhighlight lang="pl/i">twoci: Proc Options(main);
Dcl 1 *(5),
Dcl 1 *(5),
2 m1x Dec Float Init(0.1234, 0,0.1234,0.1234,0.1234),
2 m1x Dec Float Init(0.1234, 0,0.1234,0.1234,0.1234),
Line 3,086: Line 3,043:
0.1234 0.9876 0.1234 0.9876 0 radius of zero gives no circles.
0.1234 0.9876 0.1234 0.9876 0 radius of zero gives no circles.
</pre>
</pre>

=={{header|PureBasic}}==
=={{header|PureBasic}}==
<syntaxhighlight lang=PureBasic>DataSection
<syntaxhighlight lang="purebasic">DataSection
DataStart:
DataStart:
Data.d 0.1234, 0.9876, 0.8765, 0.2345, 2.0
Data.d 0.1234, 0.9876, 0.8765, 0.2345, 2.0
Line 3,131: Line 3,087:
No circles possible.
No circles possible.
Illegal radius.</pre>
Illegal radius.</pre>

=={{header|Python}}==
=={{header|Python}}==
The function raises the ValueError exception for the special cases
The function raises the ValueError exception for the special cases
and uses try - except to catch these and extract the exception detail.
and uses try - except to catch these and extract the exception detail.


<syntaxhighlight lang=python>from collections import namedtuple
<syntaxhighlight lang="python">from collections import namedtuple
from math import sqrt
from math import sqrt


Line 3,219: Line 3,174:
You can construct the following circles:
You can construct the following circles:
ERROR: radius of zero</pre>
ERROR: radius of zero</pre>

=={{header|Racket}}==
=={{header|Racket}}==
Using library `plot/utils` for simple vector operations.
Using library `plot/utils` for simple vector operations.


<syntaxhighlight lang=racket>
<syntaxhighlight lang="racket">
#lang racket
#lang racket
(require plot/utils)
(require plot/utils)
Line 3,272: Line 3,226:
Drawing circles:
Drawing circles:


<syntaxhighlight lang=racket>
<syntaxhighlight lang="racket">
(require 2htdp/image)
(require 2htdp/image)


Line 3,289: Line 3,243:
(empty-scene 100 100))
(empty-scene 100 100))
</syntaxhighlight>
</syntaxhighlight>

=={{header|Raku}}==
=={{header|Raku}}==
(formerly Perl 6)
(formerly Perl 6)
{{works with|Rakudo|2020.08.1}}
{{works with|Rakudo|2020.08.1}}
<syntaxhighlight lang=raku line>multi sub circles (@A, @B where ([and] @A Z== @B), 0.0) { 'Degenerate point' }
<syntaxhighlight lang="raku" line>multi sub circles (@A, @B where ([and] @A Z== @B), 0.0) { 'Degenerate point' }
multi sub circles (@A, @B where ([and] @A Z== @B), $) { 'Infinitely many share a point' }
multi sub circles (@A, @B where ([and] @A Z== @B), $) { 'Infinitely many share a point' }
multi sub circles (@A, @B, $radius) {
multi sub circles (@A, @B, $radius) {
Line 3,326: Line 3,279:
for it often makes calculations easier with plane geometry:
for it often makes calculations easier with plane geometry:


<syntaxhighlight lang=raku line>multi sub circles ($a, $b where $a == $b, 0.0) { 'Degenerate point' }
<syntaxhighlight lang="raku" line>multi sub circles ($a, $b where $a == $b, 0.0) { 'Degenerate point' }
multi sub circles ($a, $b where $a == $b, $) { 'Infinitely many share a point' }
multi sub circles ($a, $b where $a == $b, $) { 'Infinitely many share a point' }
multi sub circles ($a, $b, $r) {
multi sub circles ($a, $b, $r) {
Line 3,353: Line 3,306:
0.1234+0.9876i, 0.8765+0.2345i, 0.5: Too far apart
0.1234+0.9876i, 0.8765+0.2345i, 0.5: Too far apart
0.1234+0.9876i, 0.1234+0.9876i, 0: Degenerate point</pre>
0.1234+0.9876i, 0.1234+0.9876i, 0: Degenerate point</pre>

=={{header|REXX}}==
=={{header|REXX}}==
{{trans|XPL0}}
{{trans|XPL0}}


<br>The REXX language doesn't have a &nbsp; '''sqrt''' &nbsp; function, &nbsp; so one is included below.
<br>The REXX language doesn't have a &nbsp; '''sqrt''' &nbsp; function, &nbsp; so one is included below.
<syntaxhighlight lang=rexx>/*REXX pgm finds 2 circles with a specific radius given 2 (X1,Y1) and (X2,Y2) ctr points*/
<syntaxhighlight lang="rexx">/*REXX pgm finds 2 circles with a specific radius given 2 (X1,Y1) and (X2,Y2) ctr points*/
@.=; @.1= 0.1234 0.9876 0.8765 0.2345 2
@.=; @.1= 0.1234 0.9876 0.8765 0.2345 2
@.2= 0 2 0 0 1
@.2= 0 2 0 0 1
Line 3,398: Line 3,350:
0.1234 0.9876 0.1234 0.9876 0 ───► radius of zero gives no circles.
0.1234 0.9876 0.1234 0.9876 0 ───► radius of zero gives no circles.
</pre>
</pre>

=={{header|Ring}}==
=={{header|Ring}}==
<syntaxhighlight lang=ring>
<syntaxhighlight lang="ring">
# Project : Circles of given radius through two points
# Project : Circles of given radius through two points


Line 3,488: Line 3,439:
It will be a single point (0.1234,0.9876) of radius 0
It will be a single point (0.1234,0.9876) of radius 0
</pre>
</pre>

=={{header|Ruby}}==
=={{header|Ruby}}==
{{trans|Python}}
{{trans|Python}}
<syntaxhighlight lang=ruby>Pt = Struct.new(:x, :y)
<syntaxhighlight lang="ruby">Pt = Struct.new(:x, :y)
Circle = Struct.new(:x, :y, :r)
Circle = Struct.new(:x, :y, :r)


Line 3,564: Line 3,514:
#<struct Circle x=0.1234, y=0.9876, r=0.0>
#<struct Circle x=0.1234, y=0.9876, r=0.0>
</pre>
</pre>

=={{header|Run BASIC}}==
=={{header|Run BASIC}}==
<syntaxhighlight lang=rnbasic>
<syntaxhighlight lang="rnbasic">
html "<TABLE border=1>"
html "<TABLE border=1>"
html "<tr bgcolor=wheat align=center><td>No.</td><td>x1</td><td>y1</td><td>x2</td><td>y2</td><td>r</td><td>cir x1</td><td>cir y1</td><td>cir x2</td><td>cir y2</td></tr>"
html "<tr bgcolor=wheat align=center><td>No.</td><td>x1</td><td>y1</td><td>x2</td><td>y2</td><td>r</td><td>cir x1</td><td>cir y1</td><td>cir x2</td><td>cir y2</td></tr>"
Line 3,626: Line 3,575:
<TD ALIGN="LEFT" COLSPAN="4">It will be a single point (0.1234,0.9876) of radius 0</TD></TR>
<TD ALIGN="LEFT" COLSPAN="4">It will be a single point (0.1234,0.9876) of radius 0</TD></TR>
</TABLE>
</TABLE>

=={{header|Rust}}==
=={{header|Rust}}==
{{trans|C}}
{{trans|C}}
<syntaxhighlight lang=rust>use std::fmt;
<syntaxhighlight lang="rust">use std::fmt;


#[derive(Clone,Copy)]
#[derive(Clone,Copy)]
Line 3,703: Line 3,651:
Points: ((0.1234, 0.9876), (0.1234, 0.9876)), Radius: 0.0000
Points: ((0.1234, 0.9876), (0.1234, 0.9876)), Radius: 0.0000
No circles can be drawn through (0.1234, 0.9876)</pre>
No circles can be drawn through (0.1234, 0.9876)</pre>

=={{header|Scala}}==
=={{header|Scala}}==
<syntaxhighlight lang=scala>import org.scalatest.FunSuite
<syntaxhighlight lang="scala">import org.scalatest.FunSuite
import math._
import math._


Line 3,767: Line 3,714:
(0.1234, 0.9876) (0.8765, 0.2345) 0.5: radius is less then the distance between points
(0.1234, 0.9876) (0.8765, 0.2345) 0.5: radius is less then the distance between points
(0.1234, 0.9876) (0.1234, 0.9876) 0.0: radius of zero yields no circlesEmpty test suite.</pre>
(0.1234, 0.9876) (0.1234, 0.9876) 0.0: radius of zero yields no circlesEmpty test suite.</pre>

=={{header|Scheme}}==
=={{header|Scheme}}==


<syntaxhighlight lang=scheme>
<syntaxhighlight lang="scheme">
(import (scheme base)
(import (scheme base)
(scheme inexact)
(scheme inexact)
Line 3,843: Line 3,789:
p1: (0.1234 0.9876) p2: (0.1234 0.9876) r: 0.0 => ((0.1234 0.9876))
p1: (0.1234 0.9876) p2: (0.1234 0.9876) r: 0.0 => ((0.1234 0.9876))
</pre>
</pre>

=={{header|Seed7}}==
=={{header|Seed7}}==
<syntaxhighlight lang=seed7>$ include "seed7_05.s7i";
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "float.s7i";
include "float.s7i";
include "math.s7i";
include "math.s7i";
Line 3,931: Line 3,876:
Radius of zero. No circles can be drawn through (0.1234, 0.9876)
Radius of zero. No circles can be drawn through (0.1234, 0.9876)
</pre>
</pre>

=={{header|Sidef}}==
=={{header|Sidef}}==
{{trans|Raku}}
{{trans|Raku}}
<syntaxhighlight lang=ruby>func circles(a, b, r) {
<syntaxhighlight lang="ruby">func circles(a, b, r) {


if (a == b) {
if (a == b) {
Line 3,977: Line 3,921:
0.1234+0.9876i, 0.1234+0.9876i, 0: Degenerate point
0.1234+0.9876i, 0.1234+0.9876i, 0: Degenerate point
</pre>
</pre>

=={{header|Stata}}==
=={{header|Stata}}==
Each circle center is the image of B by the composition of a rotation and homothecy centered at A. It's how the centers are computed in this implementation. The coordinates are returned as the columns of a 2x2 matrix. When the solution is not unique or does not exist, this matrix contains only missing values.
Each circle center is the image of B by the composition of a rotation and homothecy centered at A. It's how the centers are computed in this implementation. The coordinates are returned as the columns of a 2x2 matrix. When the solution is not unique or does not exist, this matrix contains only missing values.


<syntaxhighlight lang=stata>real matrix centers(real colvector a, real colvector b, real scalar r) {
<syntaxhighlight lang="stata">real matrix centers(real colvector a, real colvector b, real scalar r) {
real matrix rot
real matrix rot
real scalar d, u, v
real scalar d, u, v
Line 4,003: Line 3,946:
Examples:
Examples:


<syntaxhighlight lang=stata>:a=0.1234\0.9876
<syntaxhighlight lang="stata">:a=0.1234\0.9876
:b=0.8765\0.2345
:b=0.8765\0.2345
: centers(a,b,2)
: centers(a,b,2)
Line 4,041: Line 3,984:
2 | .9876 .9876 |
2 | .9876 .9876 |
+-----------------+</syntaxhighlight>
+-----------------+</syntaxhighlight>

=={{header|Swift}}==
=={{header|Swift}}==


{{trans|F#}}
{{trans|F#}}


<syntaxhighlight lang=swift>import Foundation
<syntaxhighlight lang="swift">import Foundation


struct Point: Equatable {
struct Point: Equatable {
Line 4,133: Line 4,075:
No ans
No ans
No ans</pre>
No ans</pre>

=={{header|Tcl}}==
=={{header|Tcl}}==
{{trans|Python}}
{{trans|Python}}
<syntaxhighlight lang=tcl>proc findCircles {p1 p2 r} {
<syntaxhighlight lang="tcl">proc findCircles {p1 p2 r} {
lassign $p1 x1 y1
lassign $p1 x1 y1
lassign $p2 x2 y2
lassign $p2 x2 y2
Line 4,170: Line 4,111:


{{out|Demo}}
{{out|Demo}}
<syntaxhighlight lang=tcl>foreach {p1 p2 r} {
<syntaxhighlight lang="tcl">foreach {p1 p2 r} {
{0.1234 0.9876} {0.8765 0.2345} 2.0
{0.1234 0.9876} {0.8765 0.2345} 2.0
{0.0000 2.0000} {0.0000 0.0000} 1.0
{0.0000 2.0000} {0.0000 0.0000} 1.0
Line 4,201: Line 4,142:
Circle:(0.1234, 0.9876, 0.0)
Circle:(0.1234, 0.9876, 0.0)
</pre>
</pre>

=={{header|VBA}}==
=={{header|VBA}}==
{{trans|Phix}}<syntaxhighlight lang=vb>Public Sub circles()
{{trans|Phix}}<syntaxhighlight lang="vb">Public Sub circles()
tests = [{0.1234, 0.9876, 0.8765, 0.2345, 2.0; 0.0000, 2.0000, 0.0000, 0.0000, 1.0; 0.1234, 0.9876, 0.1234, 0.9876, 2.0; 0.1234, 0.9876, 0.8765, 0.2345, 0.5; 0.1234, 0.9876, 0.1234, 0.9876, 0.0}]
tests = [{0.1234, 0.9876, 0.8765, 0.2345, 2.0; 0.0000, 2.0000, 0.0000, 0.0000, 1.0; 0.1234, 0.9876, 0.1234, 0.9876, 2.0; 0.1234, 0.9876, 0.8765, 0.2345, 0.5; 0.1234, 0.9876, 0.1234, 0.9876, 0.0}]
For i = 1 To UBound(tests)
For i = 1 To UBound(tests)
Line 4,243: Line 4,183:
points {0,1234, 0,9876}, {0,8765, 0,2345} with radius 0,5 ==> too far apart 1,06504423382318 > 1
points {0,1234, 0,9876}, {0,8765, 0,2345} with radius 0,5 ==> too far apart 1,06504423382318 > 1
points {0,1234, 0,9876}, {0,1234, 0,9876} with radius 0 ==> same points/radius is zero</pre>
points {0,1234, 0,9876}, {0,1234, 0,9876} with radius 0 ==> same points/radius is zero</pre>

=={{header|Visual Basic .NET}}==
=={{header|Visual Basic .NET}}==
{{trans|C#}}
{{trans|C#}}
<syntaxhighlight lang=vbnet>Public Class CirclesOfGivenRadiusThroughTwoPoints
<syntaxhighlight lang="vbnet">Public Class CirclesOfGivenRadiusThroughTwoPoints
Public Shared Sub Main()
Public Shared Sub Main()
For Each valu In New Double()() {
For Each valu In New Double()() {
Line 4,325: Line 4,264:
Points (0.1234, 0.9876) and (0.2345, 0.8765) with radius 0:
Points (0.1234, 0.9876) and (0.2345, 0.8765) with radius 0:
No circles.</pre>
No circles.</pre>

=={{header|Visual FoxPro}}==
=={{header|Visual FoxPro}}==
Translation of BASIC.
Translation of BASIC.
<syntaxhighlight lang=vfp>
<syntaxhighlight lang="vfp">
LOCAL p1 As point, p2 As point, rr As Double
LOCAL p1 As point, p2 As point, rr As Double
CLOSE DATABASES ALL
CLOSE DATABASES ALL
Line 4,443: Line 4,381:
Points are coincident.
Points are coincident.
</pre>
</pre>

=={{header|Vlang}}==
=={{header|Vlang}}==
{{trans|Go}}
{{trans|Go}}
<syntaxhighlight lang=vlang>import math
<syntaxhighlight lang="vlang">import math


const (
const (
Line 4,599: Line 4,536:
}
}
</pre>
</pre>

=={{header|Wren}}==
=={{header|Wren}}==
{{trans|Go}}
{{trans|Go}}
{{libheader|Wren-math}}
{{libheader|Wren-math}}
<syntaxhighlight lang=ecmascript>import "/math" for Math
<syntaxhighlight lang="ecmascript">import "/math" for Math


var Two = "Two circles."
var Two = "Two circles."
Line 4,698: Line 4,634:
Center: (0.1234, 0.9876)
Center: (0.1234, 0.9876)
</pre>
</pre>

=={{header|XPL0}}==
=={{header|XPL0}}==
An easy way to solve this:
An easy way to solve this:
Line 4,708: Line 4,643:
The method used here is a streamlining of these steps.
The method used here is a streamlining of these steps.


<syntaxhighlight lang=XPL0>include c:\cxpl\codes;
<syntaxhighlight lang="xpl0">include c:\cxpl\codes;


proc Circles; real Data; \Show centers of circles, given points P & Q and radius
proc Circles; real Data; \Show centers of circles, given points P & Q and radius
Line 4,742: Line 4,677:
Radius = zero gives no circles
Radius = zero gives no circles
</pre>
</pre>


=={{header|Yabasic}}==
=={{header|Yabasic}}==
{{trans|Liberty BASIC}}
{{trans|Liberty BASIC}}
<syntaxhighlight lang=Yabasic>
<syntaxhighlight lang="yabasic">
sub twoCircles (x1, y1, x2, y2, radio)
sub twoCircles (x1, y1, x2, y2, radio)
if x1 = x2 and y1 = y2 then //Si los puntos coinciden
if x1 = x2 and y1 = y2 then //Si los puntos coinciden
Line 4,791: Line 4,724:


</syntaxhighlight>
</syntaxhighlight>


=={{header|zkl}}==
=={{header|zkl}}==
{{trans|C}}
{{trans|C}}
<syntaxhighlight lang=zkl>fcn findCircles(a,b, c,d, r){ //-->T(T(x,y,r) [,T(x,y,r)]))
<syntaxhighlight lang="zkl">fcn findCircles(a,b, c,d, r){ //-->T(T(x,y,r) [,T(x,y,r)]))
delta:=(a-c).hypot(b-d);
delta:=(a-c).hypot(b-d);
switch(delta){ // could just catch MathError
switch(delta){ // could just catch MathError
Line 4,843: Line 4,774:
Circles: singularity
Circles: singularity
</pre>
</pre>

=={{header|ZX Spectrum Basic}}==
=={{header|ZX Spectrum Basic}}==
{{trans|Liberty BASIC}}
{{trans|Liberty BASIC}}
<syntaxhighlight lang=zxbasic>10 FOR i=1 TO 5
<syntaxhighlight lang="zxbasic">10 FOR i=1 TO 5
20 READ x1,y1,x2,y2,r
20 READ x1,y1,x2,y2,r
30 PRINT i;") ";x1;" ";y1;" ";x2;" ";y2;" ";r
30 PRINT i;") ";x1;" ";y1;" ";x2;" ";y2;" ";r
Line 4,873: Line 4,803:
1200 PRINT "(";cx-dy;",";cy-dx;")"
1200 PRINT "(";cx-dy;",";cy-dx;")"
1210 RETURN</syntaxhighlight>
1210 RETURN</syntaxhighlight>

[[Category:Geometry]]