[OpenJDK 2D-Dev] X11 uniform scaled wide lines and dashed lines; STROKE_CONTROL in Pisces
dlila at redhat.com
Sat Dec 25 00:43:27 UTC 2010
> Unfortunately, this means that the names here
> and the values assigned to them and the comment above them conflict.
> If the variables could be named "p/3" and "q/2" then all would be clear,
> but I don't know how to do that naming very easily. Perhaps the
> comment could be simply reworded:
> // substitute <blah blah blah>
> // x^3 + Px + Q = 0
> // Since we actually need P/3 and Q/2 for all of the
> // calculations that follow, we will calculate
> // p = P/3
> // q = Q/2
> // instead and use those values for simplicity of the code.
Good point. Done.
> Line 1105 - single quotes in comments freaks out my version of
> I usually try to avoid them, except in pairs, but there isn't a better
> way to word this comment. :-(
We could always go with "the method of Cardano", although
that doesn't sound good at all. Or we could use a backtick instead of
the single quote - it looks similar enough.
> Lines 1157-1163 - the old code used to copy the eqn before it got
> clobbered with roots. Here it is too late. You probably need to move
> this code up near line 1135 before the 3 roots are stuffed into the
> res array. (Did you test the eqn==res case?)
You're right. I'm sorry about this.
> I noticed that the "Casus irreducibilis" case isn't in Cordano's
> He only finds roots for the 1 and 2 root case and punts for 3 roots.
> So, this is someone else's method. It would be nice to figure out who
> or what and list a reference, even though the Graphics Gems and the
> code didn't. The closest reference I can find is unattributed on
> Wikipedia, but you could include it in a comment for reference:
> Line 1133 - I don't understand why that term has -q in it. The above
> link and the original code both computed essentially the arccos of
> formula without the negation of q. ??? Since acos(-v) == pi - acos(v)
> this would seem to negate the result and bias it by pi/3. Negating it
> won't affect the eventual cosine, but the bias by pi/3 will. Am I
> missing something?
I think you are. What's going on is that our code is computing
ret = t2, ret = t0, ret = t1, where (t0, t1, t2 are the tk's
from the wikipedia link).
Let X = (3q/2p)*sqrt(-3/p) where p and q are the ones from the wikipedia
article, not our code.
So, when we do ret = t * cos(phi), that's:
= t * cos(acos(-X))
= t * cos(pi/3 - acos(X))
= t * cos(acos(X) - pi/3)
= t * cos(acos(X) - pi/3 - pi)
= t * cos(acos(X) - 2*2*pi/3)
ret and ret are very similar to prove - you just add/subtract pi/3
from the argument to cos.
I unfortunately don't have access to the icedtea servers at this moment,
so I attached a patch. I hope that's ok.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 5299 bytes
Desc: not available
More information about the 2d-dev