For Programmers: Free Programming Magazines  


Home > Archive > AWK > September 2006 > create ellipse from line









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author create ellipse from line
durant

2006-09-15, 3:56 am

i am trying to find an awk solution to create the x,y points for an
ellipse drawn around a line.

the input will be two sets of XY values which will represent the axis
of the ellipse. it would be nice to have variables sch as maximum width
or total area for the ellipse.

i realize this is complicated, but i was just looking for an awk
solution since i am familiar with that.

thank you,
durant
durant_greenwood@sbcglobal.net

Ed Morton

2006-09-15, 3:56 am

durant wrote:

> i am trying to find an awk solution to create the x,y points for an
> ellipse drawn around a line.
>
> the input will be two sets of XY values which will represent the axis
> of the ellipse. it would be nice to have variables sch as maximum width
> or total area for the ellipse.
>
> i realize this is complicated, but i was just looking for an awk
> solution since i am familiar with that.
>
> thank you,
> durant
> durant_greenwood@sbcglobal.net
>


You may actually have better luck at the gnuplot NG
(comp.graphics.apps.gnuplot) since they use awk quite a bit for plotting
graphics.

Ed.
mjc

2006-09-15, 3:56 am


durant wrote:
> i am trying to find an awk solution to create the x,y points for an
> ellipse drawn around a line.
>
> the input will be two sets of XY values which will represent the axis
> of the ellipse. it would be nice to have variables sch as maximum width
> or total area for the ellipse.
>
> i realize this is complicated, but i was just looking for an awk
> solution since i am familiar with that.
>
> thank you,
> durant
> durant_greenwood@sbcglobal.net


There is not enough information if you just give the endpoints of one
axis - you need both the major and minor axes.

If the major axis is parallel to the x axis, the equation is of the
form

((x-p)/a)^2 + ((y-q)/b)^2 = 1.

The points are of the form (p+a*cos(t), q+b*sin(t)), where t goes from
0 to 2*pi. There are various ways of parameterizing t to draw the
ellipse nicely.

If the major axis is not parallel, you have to rotate these points.

The problem is not in awk, it is in the math.

Martin Cohen

Jürgen Kahrs

2006-09-15, 3:56 am

mjc wrote:

> The problem is not in awk, it is in the math.


Yes, and a good introduction into the math is

http://en.wikipedia.org/wiki/Bresen..._line_algorithm
http://www.spiritone.com/~joeltr/polygonwar2_00000b.htm
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com