Thanks bplus!
I think in practice, the second function (Without the alias problem) will be the keeper. Since it relies on PAINT for filling, it has to be its own image or whatever if we want to place it over other shapes, of course.
Just so it's all in one place, here is the derivation of the equations in the second function.
Vectors are in bold.(1)Recall that an un-tilted ellipse with major and minor axes
a,
b, respectively, centered at the point (
0,
0) can be represented by a vector
r0 and an angular parameter
q, namely
r0 =
i a cos(q) +
j b sin (q) ,
where unit vectors
i = (
1,
0) and
j = (
0,
1) align with the horizontal and vertical directions, respectively.
(As a quick aside, it's trivial to eliminate the parameter
q in the above to arrive at (x/a)^2 + (y/b)^2 = 1.)
(2)It must follow that a tilted ellipse aligns with a different pair of unit vectors
u and
v in place of
i and
j. Whatever
u and
v are, the tilted ellipse obeys:
r =
u a cos(q) +
v b sin (q)
(3)The next task is to determine
u and
v in terms of
i and
j. For
i and
j to "swing into"
u and
v across angle
w, we apply a rotation matrix as follows:
u =
i cos(w) -
j sin(w)
v =
i sin(w) +
j cos(w)
(4)Plugging the new equations for
u and
v into
r, we find:
r = (
i cos(w) -
j sin(w)) a cos(q) + (
i sin(w) +
j cos(w)) b sin(q)
r =
i (a cos(q) cos(w) + b sin (q) sin(w)) +
j (-a cos(q)sin(w) + b sin(q) sin(w))
(5)Isolate the
i and
j components to finally land at equations for
x and
yx = a cos(q) cos(w) + b sin (q) sin(w)
y = -a cos(q)sin(w) + b sin(q) sin(w)... and these are precisely what are implemented in the code (which uses slightly different notation)