|
From: Pierre <pie...@gm...> - 2007-02-07 14:38:19
|
Hi, The code has added in the new playground module in libgd CVS: http://cvs.php.net/viewvc.cgi/gd/playground/gdimageshadedtriangle/ This version contains the last patch from Daniel. By the way, if you like to have CVS access, please let me know. I think it may improve the testing process. On 2/7/07, Daniel J Sebald <dan...@ie...> wrote: > Hans-Bernhard Br=F6ker wrote: > > Daniel J Sebald wrote: > > > >>I've looked through the code a bit and your examples. (What command > >>does one need to compile this program?) I'd have to think about your > >>approach to be certain about the result. You've broken the thing down > >>into a series of one dimensional linearities, first along the sides of > >>the triangle to get a color, and then across the x dimension to further > >>interpolate between those two. Seems logical, but it may be open for > >>rounding problems. > > > > > > And, more importantly, it's a bit biased, which tends to turn into a > > robustness problem. The bias lies in the arbitrary choice of one verte= x > > to be shared by the two first interpolations. > > > > It can be better to go via barycentric coordinates. It's effectively a > > method to find three numbers s, t, and u such that: > > > > s+t+u=3D1 > > s*A + t*B + u*C =3D X for the point, and its colour. > > > > I.e. you solve the equation for s,t,u given a point X, then substitute > > them into the equation to find the target colour. > > Interesting. This results in matrix equations similar to what I sent pre= viously: I'm not sure to understand why it is biased. Each vertex color is known. The first vertex is the top left one, after they have been sorted. Or is it something you will do outside the function to define the color at each vertex? Is it about having a higher precision for the interpolation (instead of the linear interpolation)? Maybe an example result may help to see the differences and their impacts in a real case. Maybe using an existing surface (one in your test cases), we can then compare all results. Pardon me if my questions are too obvious but I never looked so deeply the rounding/precision problems. it is really a good thing as it minimizes the risk of errors (no bad surprise after the releases). --Pierre |