Algorithm for drawing an ellipse

1,602 views
Skip to first unread message

ToddT

unread,
Mar 27, 2008, 11:27:52 AM3/27/08
to KML Developer Support - Advanced Support for KML
I hope somebody can help.

I need to draw an ellipse in GE. I'm given a horizonal and width
distance along with a lat/lon representing the center of the ellipse.
Does somebody have an algorithm that will generate the KML used to
display the ellipse.

Note - I need the algorthim, rather than a 3rd-party tool that will
generate a KML file, because I will be obtaining the data from a
database and displaying the associated ellipse in my own app that
hosts GE (i.e., I'm not using the client GE app).

Thx in advance.

todd

barryhunter [KML Guru]

unread,
Mar 28, 2008, 1:03:54 PM3/28/08
to KML Developer Support - Advanced Support for KML
There are plenty of scripts available for plotting circles
http://www.google.co.uk/search?q=circle+kml
many with source available.

Of course a circle is a special ellipise with the same width and
height, so just supply a different size to the two controlling factors
(usually one using sin and the other cos).

This is assuming that the height and width are parellel and
perpendicular to the north-south and east-west lines - but it shouldnt
be difficult to find the formular for arbitary rotations. (I've just
never had the need myself)

mwill

unread,
Apr 2, 2008, 2:54:59 AM4/2/08
to KML Developer Support - Advanced Support for KML

Todd,

Funny you should ask this, I am in the middle of writing just such
an algorithm. There is nothing special about it, I'm sure my solution
is not anything special. However, I don't understand the information
you are using to define the ellipse. From what I gathered you have
the major and minor axes. But to properly plot an ellipse you also
need some kind of orientation, unless, of course, all of your ellipses
are aligned the same way, and then it could be assumed. If you could
give me an example of the data you have for one of your ellipses I may
be able to help you out.

mwill

Scott

unread,
Apr 11, 2008, 9:20:11 AM4/11/08
to KML Developer Support - Advanced Support for KML
mwill,

I agree, I am looking into doing a very similar thing right now using
a center point, a major/minor axis and an orientation.

Any progress on your end?

-Scott

On Apr 2, 2:54 am, mwill wrote:
> Todd,
>
> Funny you should ask this, I am in the middle of writing just such
> an algorithm. There is nothing special about it, I'm sure my solution
> is not anything special. However, I don't understand the information
> you are using to define theellipse. From what I gathered you have
> the major and minor axes. But to properly plot anellipseyou also

mwill

unread,
Apr 11, 2008, 9:54:08 AM4/11/08
to KML Developer Support - Advanced Support for KML

Scott,
Only in my head so far. I am planning on actually putting pen to
paper next week while I do a major upgrade to an application at work.
However, I'm not starting from scratch. I already have an algorithm
that plots a new lat/long when given a lat/long, bearing, and
distance. I use this for plotting circles by running it through
360deg.

To modify this for an ellipse I just have to calculate the constantly
changing "radius" of the ellipse. My plan is to calculate the X and Y
coordinates of the ellipse using the parametric formula for an ellipse
at a given degree and then calculate the distance of that point from
the center of the ellipse which is the "radius" of the ellipse. Then
I'll take that distance at the given degree, and plot it in the
algorithm I already have.

mwill
> > mwill- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages