I am looking for a Ellipse algorithm, and I can't find any without specifying steps.
here is an algorithm I found:
can anyone help me solve this algorithm problem or get me a new one.
thanks.
here is an algorithm I found:
Code:
function calculateEllipse(x, y, a, b, angle, steps){ if (steps == null) steps = 36; var points = []; // Angle is given by Degree Value var beta = -angle * (Math.PI / 180); //(Math.PI/180) converts Degree Value into Radians var sinbeta = Math.sin(beta); var cosbeta = Math.cos(beta); for (var i = 0; i < 360; i += 360 / steps) { var alpha = i * (Math.PI / 180) ; var sinalpha = Math.sin(alpha); var cosalpha = Math.cos(alpha); var X = Math.floor(x + (a * cosalpha * cosbeta - b * sinalpha * sinbeta)); var Y = Math.floor(y + (a * cosalpha * sinbeta + b * sinalpha * cosbeta)); drawPixel(X,Y); } }
thanks.
Comment