[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: gEDA-user: pcb GL can't render stretched arcs
On Fri, Jul 15, 2011 at 09:45:42PM +0200, Karl Hammar wrote:
> Andrew Poelstra:
> > I am using the polar form of the ellipse given at:
> >
> > http://en.wikipedia.org/wiki/Ellipse#Polar_form_relative_to_center
> >
> > with theta the angle of the point we are checking. (Those cos
> > and sin calculations are easy, just delta-x/len and delta-y/len.)
> > With that I can calculate the distance from the point to an
> > ellipse.
>
> The shortest line from (x,y) to the ellipse goes through the normal to
> the ellipses perimeter.
>
Ohh... of course. Darn.
> The normal does not generally go through the middlepoint of the ellipse.
> It crosses the line between the center and the nearest focal point.
>
> What you get with the above polar calculation is a little bigger value
> than the true distance, but it could serve as a first aproximation.
> You could take the minimum of the polar form through the center and
> through the focus, to get a better value.
>
> How accurate an value do we need, would minimum of ±5% and ±0.1mm
> be ok ?
>
I suspect that determining an error bound on my method would be
just as difficult (mathematically) as finding a different method.
There is a fairly informative discussion of this problem on SO:
http://stackoverflow.com/questions/2945337/how-to-detect-if-an-ellipse-intersectscollides-with-a-circle
The correct methods given there generally require root-solvers,
and I don't think we have one right now. We could throw one
together or introduce a dependency on, say, the GNU Scientific
Library.
Since we rarely care about the exact distance, only "is it between
0 and Radius" it is probable that we could use a bisection method
with very few iterations to get an answer.
> > Restricting this to an ellipse /segment/ is tricky, since as DJ
> > pointed out, these are not "real" elliptical arcs, but stretched
> > arcs, so the limiting angles do not correspond directly to actual
> > angles.
> ...
>
> Isn't that a bug to be fixed instead?
>
It's a design flaw, but "fixing" it would break existing designs.
--
Andrew Poelstra
Email: asp11 at sfu.ca OR apoelstra at wpsoftware.net
Web: http://www.wpsoftware.net/andrew/
_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user