
-----------------------------------
whoareyou
Fri Mar 09, 2012 9:43 pm

Elliptical Path
-----------------------------------
I'm trying to have a basic circle follow in a circular path around the console window. However, the console window isn't a perfect square, so an elliptical path makes more sense. Before I can implement the PATH, I need to first understand how to draw an actual ellipse.

I'm trying to follow the formulas found on the Wikipedia site for an Ellipse:
 http://upload.wikimedia.org/wikipedia/en/math/2/e/7/2e7d6dce07cd9ad4da7e99620e42837e.png
http://upload.wikimedia.org/wikipedia/en/math/f/d/3/fd3b359a461578ccdc670e50712579f6.png
Link: http://en.wikipedia.org/wiki/Ellipse#General_parametric_form

When I implemented this in my Java program, it produced this image:
http://i.imgur.com/Nlc7a.jpg

This path, draw in the black, goes off of the console window, and I'm trying to make the x and y coordinates so that I can use it with a different object (perhaps a rectangle following an elliptical path across the console window). I want the path to look like the ellipse in RED, but everything I do doesn't seem to work. Any suggestions?

[code]
// The "MoveCircle" class.
import java.awt.*;
import hsa.Console;

public class MoveCircle
{
    static Console c;           // The output console

    public static void main (String[] args) throws InterruptedException
    {
        c = new Console ();

        int x, y, width, height, xCenter, yCenter;
        x = c.maxx () / 2;
        y = c.maxy () / 2;
        width = 50;
        height = 50;
        xCenter = width / 2;
        yCenter = height / 2;

        for (int i = 0 ; i 