#### Archived

This topic is now archived and is closed to further replies.

# ellipse problem

This topic is 5455 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have an ellipse center 0,0 majour axis radious 5 minor axis radious 2 i.e 2 | | | |----------------------5 does any one know how to generate the points for this ellipse for every degree i.e for(i=0; i<360; ++i) thanks

##### Share on other sites
sin() returns the y values for a unit circle and cos() returns the x values on an unit circle, thus, given the half_width (5 in your case) and the half_height (2 in your case) this would get you what you want:

double half_width  = 5;double half_height = 2; for ( int i = 0; i < 360; i++ ){   double a = degrees_to_radians(i); /* C/C++ sin/cos needs andgle in radians not degrees */   printf( "x = %lf y = %lf", half_width*cos(a), half_height*cos(a) );}....double degrees_to_radians( double degrees ){   /* with some comilers this could be:      static conversion = M_PI / 180.0; */   static double conversion = 3.1415926535 / 180.0;    return conversion * degrees;}

Unchecked code: may have errors

[edited by - mauman on October 15, 2003 9:47:57 AM]

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
16
5. 5

• 9
• 12
• 9
• 33
• 13
• ### Forum Statistics

• Total Topics
632593
• Total Posts
3007271

×