JUL
20
2010

GSoC: Transformation Tool for KritaIt's been two weeks since my last blog entry, so I thought it was time I gave an update about my work. The next step was to add perspective transformation to the tool, and the least I can say is it wasn't easy. For those interested, here is the formula I used for the perspective projection : where (cx, cy, cz) is the position of the camera and (ex, ey, ez) is the eye position. I took respectively (0, 0, 1024) for the camera and (0, 0, 1024) for the eye. To invert the perspective transformation, I had to solve the following 3x3 system of equations : The last equation is the equation of the plane your points were before perspective projection. The parameters (a, b, c) can be found by calculating the cross product of two (non colinear) vectors of the plane. For those who are interested, here is the solution : But don't think that the work is done once I have the formulas ! I managed to make translation, rotations, shearing and rotation center movement work correctly with perspective, but not scaling. I even tried to find the exact solution with Maple, but as I expected, it couldn't solve a 44 nonlinear system of equations (the unknowns are the two scale factors, and the translation along X and Y axis, because the opposite corner of the one grabbed must stay at its position at click).. After that, I still had to make the tool able to apply perspective transformations to the paint device. I just added a new constructor to the already existing perspective transform worker. I have already begun investigating warp transformation methods, but I am not yet ready to begin implementation. This is certainly the most exciting part of my project, but also the scariest ! ;) 