METHOD FOR DRAWING GEOMETRIC SHAPES
A method for drawing geometric shapes comprises the steps of obtaining a request to draw at least two geometric shapes, each having assigned a depth coordinate and at least one having the depth coordinate variable across its surface, dividing the geometric shapes into rectangles such that each rectangle has a constant depth coordinate, sorting the rectangles according to the depth coordinate value and drawing the rectangles in the sorted order so as to form an output image.
1 . A method for drawing geometric shapes, the method comprising the steps of
obtaining a request to draw at least two geometric shapes, each having assigned a depth coordinate and at least one having a depth coordinate variable across its surface as a result of a rotation about a rotation axis;
dividing the geometric shapes into rectangles having a depth coordinate of constant value;
sorting the rectangles according to the depth coordinate of constant value; and
drawing the rectangles in a sorted order to form an output image.
2 . The method according to claim 1 , wherein by the drawing the rectangles for each rectangle is found a corresponding part of a texture image taking perspective correction into account and copying, with scaling, the corresponding part of the texture image in order to fit it into a rectangle being drew.
3 . The method according to claim 1 wherein the sorting the rectangles is performed by putting to a beginning of sorted queue the rectangles with the depth coordinate further from an observer.
4 . The method according to claim 1 , wherein the dividing the geometric shapes into rectangles comprises steps of
defining a two dimensional outline of a rotated source geometric shape by
performing its perspective projection onto a two dimensional plane; and
splitting the two dimensional outline, into intermediate rectangles, in places where pixel of either of the lines, non-parallel to the rotation axis, of the two dimensional outline changes coordinates wherein in case of a rotation around the Y-axis, pixel's Y-coordinate value changes by n counted from a Y-coordinate value of a previous split point or a start point of a line non-parallel to the rotation axis of the two dimensional outline and wherein in case of a rotation around the X-axis, pixel's X-coordinate value changes by n counted from an X-coordinate value of a previous split point or a start point of a line non-parallel to the rotation axis of the two dimensional outline.
5 . The method according to claim 4 wherein the lines, non-parallel to the rotation axis, of the two dimensional outline are calculated using Bresenham algorithm.
6 . The method according to claim 4 wherein the value of the n parameter is preferably 1 or −1.
7 . The method according to claim 4 wherein at least one of the intermediate rectangles has four equal sides.
8 . The method according to claim 4 wherein all depth coordinates of the Z axis of the source geometric shape have equal value.
9 . A computer program comprising program code means for performing all the steps of a method of claim 1 when said program is run on a computer.
10 . A computer readable medium having computer-executable instructions performing all the steps of the computer-implemented method according to claim 1 .