Drawing Ellipse and rotation matrix

The below equations will give you x and y coordinates of ellipse.

x = a cos t 
y = b sin t

a – horizontal distance from origin.

b – vertical distance from origin

t – angle at which you need the coordinate. enter image description here

List<Double> xcoord = new ArrayList<Double>();
List<Double> ycoord = new ArrayList<Double>();

public void getCoordinates() {
    for(int i=0;i<360;i++) {
        xcoord.add(10 * Math.cos(i));
        ycoord.add(20 * Math.sin(i));
    }
}

The above function adds up all the coordinates from 0 to 360 to the list with 10 as horizontal distance from origin and 20 as vertical distance from origin. Hope this helps.

 

 

ou may use a simple rotation transformation:

x1 = x*cos(a) - y*sin(a)
y1 = x*sin(a) + y*cos(a)

Where a – is the angle to rotate.

This Wikipedia article explains that in detail

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s