## Getting translated coordinates?

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

### Getting translated coordinates?

Hey I have a Region that bounds a part of my canvas. The canvas draws a rectangle from x1,y1 to x2,y2. Before drawing the canvas is translated by a certain amount. This causes the rectangle to get translated as well.

is it possible to calculate the position of (x1,y1) after a translation of (dx,dy) is applied to it?
asimmittal
Developer

Posts: 45
Joined: Wed Jan 19, 2011 8:35 am

### Re: Getting translated coordinates?

i think the new values should be x1+dx, y1+dy... any one confirm that?
asimmittal
Developer

Posts: 45
Joined: Wed Jan 19, 2011 8:35 am

### Re: Getting translated coordinates?

I think you can try with The Bresenham line algorithm since it is an algorithm which determines which points in an n-dimensional raster should be plotted in order to form a close approximation to a straight line between two given points. It is commonly used to draw lines on a computer screen, as it uses only integer addition, subtraction and bit shifting, all of which are very cheap operations in standard computer architectures. It is one of the earliest algorithms developed in the field of computer graphics. A minor extension to the original algorithm also deals with drawing circles.
roopa
Developer

Posts: 27
Joined: Wed Sep 14, 2011 6:46 am