Board index » delphi » A simple geometry question (drawing circular curves)...

A simple geometry question (drawing circular curves)...

hi all,

does some one know of a simple and efficient algorithm to draw a circular
curve in the xy plane given the start- and end point of this curve and the
radius:

can any one provide me with some pointers or suggestions or (even better)
sample code? please reply also to my email address

thanx in advance

Hans van Lint

__________________________________________________

ir. J.W.C. van Lint

Transportation Planning and
Traffic Engineering Department
Faculty of Civil Engineering and Geosciences
Delft University of Technology
Stevinweg 1, P.O. Box 5048, 2600 GA Delft
(phone) +31 (0) 15 278.50.61
(mobile) +31 (0) 6 26.25.26.39
(email) H.vanL...@citg.tudelft.nl
__________________________________________________

 

Re:A simple geometry question (drawing circular curves)...


Quote
> does some one know of a simple and efficient algorithm to draw a circular
> curve in the xy plane given the start- and end point of this curve and the
> radius:

There is one problem: There are two such curves if you don't have any
additional parameter. Start- and end point have the same distance to the
center (distance = radius), so yo search a point that's on a line
exactly between start- and end point.

       C1
       |
S------X------E
       |
       C2

To do so first search point X with
X.x := (S.x + E.x) / 2
X.y := (S.y + E.y) / 2

With pythagoras you know:
Sqr(S-X) + Sqr(X-C) = Sqr(S-C) where S-C = Radius

You also know that X-C is 90 degrees to S-X, so
C.x := X.x + f*(X.y-S.y)
C.y := X.y + f*(X.x-S.x)

Now what is f? A factor that makes C-X the right length (with the
pythagoras formula above).
sx = Sqrt(Sqr(S.x-X.x)+Sqr(S.y-X.y)) // distance between S and X
f = Sqrt(Sqr(Radius)-Sqr(sx))/sx // divide by sx because in the formula
above you have a multiplication by something like "sx" again (just
another direction but same length)

Okay, now take +f and -f and you have both centers that are possible. I
think that's all information you need to draw the curve. Right? (not
quite sure)

Well, that's just what came to my mind, not sure about all of it.

Jens

Other Threads