2

I found a couple of formulas but I can't transform them in code.

From the answer in Calculating a Point that lies on an Ellipse given an Angle , for instance, I get to:

var x = (a * b) / Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) * Math.pow(Math.tan(angle), 2));
var y = x * Math.tan(angle);

But this doesn't give the result expected.

(wanted to comment on the already created answers but I don't have enough privileges)

  • I've written a new answer to that question. Give that one a try, maybe? It's a lot simpler so it's less error prone to code. – rurouniwallace May 19 '13 at 17:16
  • That answer gives an incorrect formula, as the $\theta$ of the simple $(a \cos(\theta),b \sin(\theta))$ is not the central angle. – coffeemath May 19 '13 at 17:30
  • There is another related answer here: http://math.stackexchange.com/questions/326349/problem-with-drawing-ellipse-with-code/326429#326429. It includes some discussion of the fact that the angle $\theta$ used in $x = a\cos\theta, y=b\sin\theta$ is not the polar angle of the point $(x,y)$. This fact seems to be causing some confusion in some of the answers below (and maybe in your code, too). – bubba May 19 '13 at 23:35
  • I used that simple expression already but the result is not precise at all. If you compare the diagonal points (45, 135, ... degrees) with the one on a circle, you get almost 5 degrees off. – Nuthinking May 20 '13 at 08:03

0 Answers0