Anonymous user
Circles of given radius through two points: Difference between revisions
Circles of given radius through two points (view source)
Revision as of 18:07, 8 November 2014
, 9 years ago{{out}}
m ({{out}}) |
|||
Line 53:
MsgBox, % CircleCenter(obj[1], obj[2], obj[3], obj[4], obj[5])
}</lang>
{{out}}
0.0000 2.0000 0.0000 0.0000 1.0 > points are opposite ends of a diameter center = 0.000000,1.000000
0.1234 0.9876 0.1234 0.9876 2.0 > No circles can be drawn, points are identical
Line 59 ⟶ 60:
0.1234 0.9876 0.1234 0.9876 0.0 > No circles can be drawn, points are identical
</pre>
=={{header|BASIC}}==
{{works with|FreeBASIC}}
Line 101 ⟶ 103:
Sleep
</lang>
{{out}}
<pre>
Points (0.1234,0.9876),(0.8765,0.2345), Rad 2
Line 119 ⟶ 122:
Points are the same
</pre>
=={{header|C}}==
<lang C>
Line 186 ⟶ 190:
}
</lang>
<pre>
Case 1)
Line 436 ⟶ 440:
Radius : 0.0000
Same point because P1=P2 and r=0.
</pre>
Line 572 ⟶ 575:
end</lang>
{{out}}
<pre>
->cgr
Line 671 ⟶ 674:
apply('getsol, cons(sol, d[3]));
apply('getsol, cons(sol, d[4]));</lang>
{{out}}
<lang>apply('getsol, cons(sol, d[1]));
two solutions
Line 700 ⟶ 703:
ИПD ИПC ИПB ИПA С/П</lang>
{{in}}
''Input'': В/О x1 С/П y1 С/П x2 С/П y2 С/П radius С/П
{{out}}
''Output'': "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|Nimrod}}==
Line 754 ⟶ 761:
echo " ERROR: ", getCurrentExceptionMsg()
echo ""</lang>
{{out}}
<pre>Through points:
(x: 0.1234, y: 0.9876)
Line 888 ⟶ 895:
</pre>
for it often makes calculations easier with plane geometry:
<lang perl6>sub circles($a, $b where $b != $a, $r) {
Line 949 ⟶ 957:
End;
End;</lang>
{{out}}
<pre> x1 y1 x2 y2 r cir1x cir1y cir2x cir2y
====== ====== ====== ====== = ====== ====== ====== ======
Line 960 ⟶ 968:
=={{header|Python}}==
The function raises the ValueError exception for the special cases
and uses try - except to catch these and extract the exception detail.
<lang python>from collections import namedtuple
Line 1,077 ⟶ 1,086:
</lang>
{{out|Testing}}
<pre>
> (circle-centers #(0.1234 0.9876) #(0.8765 0.2345) 2.0)
Line 1,151 ⟶ 1,159:
cb=sqrt(r**2-pb**2); x1=y*cb/pb; y1=x*cb/pb
return f(bx-x1) f(by+y1) f(bx+x1) f(by-y1)</lang>
<pre>
x1 y1 x2 y2 radius circle1x circle1y circle2x circle2y
Line 1,360 ⟶ 1,368:
return [list $c1 $c2]
}</lang>
{{out|Demo}}
<lang tcl>foreach {p1 p2 r} {
{0.1234 0.9876} {0.8765 0.2345} 2.0
Line 1,394 ⟶ 1,403:
=={{header|XPL0}}==
An easy way to solve this
translate the coordinates so that one point is at the origin.
Then rotate the coordinate frame so that the second point is on the X-axis.
The circles' X coordinate is then half the distance to the second point.
The circles' Y coordinates are easily seen as +/-sqrt(radius^2 - circleX^2).
Now undo the rotation and translation.
The method used here is a streamlining of these steps.
|