Re: Circle center from point on circle



In article <20080221175907.249$Ua@xxxxxxxxxxxxxx>,
David W. Cantrell <DWCantrell@xxxxxxxxxxx> wrote:
rob@xxxxxxxxxxxxxx (Rob Johnson) wrote:
In article <20080221151546.892$kW@xxxxxxxxxxxxxx>,
David W. Cantrell <DWCantrell@xxxxxxxxxxx> wrote:
rob@xxxxxxxxxxxxxx (Rob Johnson) wrote:
In article <20080221112825.276$G6@xxxxxxxxxxxxxx>,
David W. Cantrell <DWCantrell@xxxxxxxxxxx> wrote:
David W. Cantrell <DWCantrell@xxxxxxxxxxx> wrote:
Anders Eriksson <andis59@xxxxxxxxx> wrote:
Hello!

I'm a programmer and need some math help!

In a cartesian coordinate system a point is specified (x1,y1).
This point is on the circle (with the radius r) and I also now
the tangent of the point (t).

You know the tangent at the specified point, and so you should also
know the slope m of that tangent.

I need to calculate the center of the circle as coordinates in
the same coordinate system (x2,y2)

The point may be anywhere in the coordinate system in all four
quadrants. I.e. x and y may be positive and negative or zero.
E.g. (-1, 0), (0,23), (25,-11), ...

You have not given enough information to determine the center of
the circle uniquely; there are possible centers on either side of
the tangent line at distance r from point (x1, y1).

The possible centers are

(x1 -/+ r/sqrt(1 + 1/m^2) , y1 +/- r/sqrt(m^2 + 1) )

Note: Opposite signs are to be used for the terms involving the
square roots.

Oops. I made a mistake. Sorry! What I gave above is incorrect
if m < 0. Correctly, the possible centers are

(x1 -/+ sign(m) r/sqrt(1 + 1/m^2) , y1 +/- r/sqrt(m^2 + 1) ).

For completeness, note that, if the tangent line is vertical, the
possible centers are (x1 +/- r, y1).

We can get rid of the sign() and unify the denominators to make
things look a little prettier with

( x1 -/+ m r/sqrt(m^2 + 1) , y1 +/- r/sqrt(m^2 + 1) )

There is a particular reason I chose not to give that form: It doesn't
work when the tangent happens to be vertical. You might object, saying
that the form I gave doesn't work when the tangent is vertical either.
But it actually does work. The slope of a vertical line is oo,
positive-or-negative infinity. For the center's y-coordinate,

y1 +/- r/sqrt(oo^2 + 1) = y1 +/- r/oo = y1 +/- 0 = y1;

for the center's x-coordinate,

x1 -/+ sign(oo) r/sqrt(1 + 1/oo^2) = x1 -/+ (+/-1) r/sqrt(1 + 0) = x1 +/- r

having taken sign(oo) to be bivalued.

BTW, the reason I had said "For completeness, note..." is merely that I
thought Anders might not want to use extended arithmetic. But my
preference is to present a single result which works in _all_ cases.

On further reflection, I regret having mentioned slope at all. Here's a
nicer method. Let (x2, y2) be any point on the tangent line, distinct
from (x1, y1). Then the possible centers of the circle are

(x1 -/+ (y2 - y1) r/sqrt((x2 - x1)^2 + (y2 - y1)^2),
y1 +/- (x2 - x1) r/sqrt((x2 - x1)^2 + (y2 - y1)^2)).

Indeed, your formula works in all cases, if one makes a few, widely
accepted, functional extensions when using the extended reals.

Actually, I was talking about just extended _arithmetic_, as used by a
computer algebra system such as Derive. (Furthermore, if all we're wanting
to do is to get the possible coordinates for the center correctly, then one
could use _positive_ infinity for the slope of a vertical line. Although
that is generally a bad idea, it would allow one to do the programming in
standard floating-point arithmetic.)

For x = oo, extend the following functions:

1/x^2 = 0

1/sqrt(x^2 + 1) = 0

In both Derive and in floating-point arithmetic, we get the above results
when x is 1/0.

sign(x) = +1 or -1 (the reader chooses)

In Derive, sign(1/0) = +/- 1. (The program does not choose.)
In floating-point arithmetic, sign(1/0) = 1.
In any event, the formula works.

My formula works in all cases as well if one makes similar functional
extensions.

Functional extensions, yes. But that goes beyond extended arithmetic. For
Anders' computer work, I think it's better to deal with just arithmetic.

For x = oo, extend the following functions:

1/sqrt(x^2 + 1) = 0

x/sqrt(x^2 + 1) = +1 or -1 (the reader chooses)

For x/sqrt(x^2 + 1), when x = 1/0, Derive yields "?" and floating-point
arithmetic yields NaN. In neither case can we continue with a useful
calculation.

At first I even wrote my formula as

( x1 -/+ r m/sqrt(m^2 + 1) , y1 +/- r/sqrt(m^2 + 1) )

so that m/sqrt(m^2 + 1) was together, to be interpreted as a single
function; but then I swapped the r and m to make it look closer to
your formula. I had assumed that you added the completeness note to
handle the case m = oo. Since you had not mentioned extended reals,
I did not realize that you had intended your formula to apply to the
extended reals.

Both formulas work in all cases, if the proper extensions are made so
that the functions are defined on the extended reals.

Right. But if we are to have "m/sqrt(m^2 + 1)" extended as your formula
requires, then we must use something beyond extended arithmetic, using,
say, something like

if(m = oo, 1, m/sqrt(m^2 + 1)).

OTOH, 1/sqrt(1 + 1/m^2) evaluates as it should using merely standard
extended arithmetic.

We are making assumptions now about the language being used. I have
no doubt that what you say is true about Derive, and I know what you
say is true about IEEE-754 floating point. However, in C, C++, and
Java, it is illegal to divide by 0, and a special case will be needed
anyway (unless the implementation allows certain non-ANSI flags to be
set which force IEEE-754 compliance).

I think you answered the original question long ago and we are going
down a path best left undisturbed. I should not have made my purely
aesthetic point in the first place. My apologies for sending us off
on this vertical tangent (m = <divide by zero exception thrown>).

Rob Johnson <rob@xxxxxxxxxxxxxx>
take out the trash before replying
to view any ASCII art, display article in a monospaced font
.



Relevant Pages

  • Re: Circle center from point on circle
    ... In a cartesian coordinate system a point is specified. ... You know the tangent at the specified point, ... functional extensions when using the extended reals. ... Functional extensions, yes. ...
    (sci.math)
  • Re: Circle center from point on circle
    ... In a cartesian coordinate system a point is specified. ... You know the tangent at the specified point, ... circle uniquely; there are possible centers on either side of the ... functional extensions when using the extended reals. ...
    (sci.math)
  • Re: Circle center from point on circle
    ... In a cartesian coordinate system a point is specified. ... You know the tangent at the specified point, and so you should also know ... circle uniquely; there are possible centers on either side of the tangent ...
    (sci.math)
  • Re: Circle center from point on circle
    ... In a cartesian coordinate system a point is specified. ... You know the tangent at the specified point, ... circle uniquely; there are possible centers on either side of the ... The slope of a vertical line is oo, ...
    (sci.math)
  • Re: Circle center from point on circle
    ... In a cartesian coordinate system a point is specified. ... You know the tangent at the specified point, and so you should also know ... You have not given enough information to determine the center of the circle ...
    (sci.math)