1
Graphics / Re: draw ellipses
« on: July 06, 2013, 07:31:03 pm »//math for ellipse
#include<cmath>
#define PI 3.1415926535898
float radius_x=50;
float radius_y=20;
unsigned short quality=70;
sf::ConvexShape ellipse;
ellipse.setPointCount(quality);
for(unsigned short i=0;i<quality;++i){
float rad=(360/quality*i)/(360/PI/2);
float x=cos(rad)*radius_x;
float y=sin(rad)*radius_y;
ellipse.setPoint(i,sf::Vector2f(x,y));
};
ellipse.setPosition(100,100);
#include<cmath>
#define PI 3.1415926535898
float radius_x=50;
float radius_y=20;
unsigned short quality=70;
sf::ConvexShape ellipse;
ellipse.setPointCount(quality);
for(unsigned short i=0;i<quality;++i){
float rad=(360/quality*i)/(360/PI/2);
float x=cos(rad)*radius_x;
float y=sin(rad)*radius_y;
ellipse.setPoint(i,sf::Vector2f(x,y));
};
ellipse.setPosition(100,100);