That depends on which coordinate system you have chosen.
If your rectangle has it's lower-left corner in the origin (0,0) then the center is at (x,y) = (5, 10), because x is half the width, and y is half the height.
You could also choose your rectangle to lie with its center in the origin. Then ofcourse the center would be at (0,0).
You could also rotate your rectangle and put it somewhere random, then you would need to draw me a diagram with appropriate angles and distances and I can show you how to work it out.
You want to transform a rectangle into a circle? How do you intend on doing that lol. Sorry I don't know what you mean.
Do you perhaps want to find a circle that lies inside the rectangle (touching the sides)?
lool you have right... what i'm trying to say is that i'm transform the rectangule coordenates that are both positive(X,Y) to the cartegian "circule".
has we know the retangule start with (0,0) to something, but the cartegian is a little diferent. work with negative values, have 4 quadrants.
heres the image:
the rectangule is in middle of cartegian(is the 1st objective), but has we know the rectangule points start in (0,0) and the Y for down is positive not negative(like the cartegian). perhaps my error is here, i don't know. but i can see the image(not in right rotation) and not complete image. i can see some space between the pixels.
thanks
Last edited by joaquim; Jun 21st, 2008 at 01:32 AM.
l
the rectangule is in middle of cartegian(is the 1st objective), but has we know the rectangule points start in (0,0) and the Y for down is positive not negative(like the cartegian). perhaps my error is here, i don't know. but i can see the image(not in right rotation) and not complete image. i can see some space between the pixels.
thanks
Are you referring to the way Pixel-coordinates are given (Y=0 at the top going down increases the value, X=0 at the left going right increases the value). This is of course different to the cartesian way to count. However that wouldn't change the calculation of your centre of rectangular object!!
If you cant see the image, I assume you try to show it using code. In order to show this rectangular at the "correct" position and "correct" rotation you need to convert the coordinates!
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button Wait, I'm too old to hurry!
If the co-ordinates of the 4 corners are (x1,y1), (x2,y2), (x3,y3), (x4,y4) then the co-ordinates of the centre are (xc,yc) where xc= (x1+x2+x3+x4)/4 and yc= (y1+y2+y3+y4)/4 and this is the case irrespective of the origin of the co-ordinates.
You can see this by considering the mid-points of (any) two opposite sides these are for example: ((x1+x2)/2, (y1+y2)/2) and ((x3+x4)/2, (y3+y4)/2). The centre is then the mid-point of these two points.
Rob
Last edited by EvoRob; Jul 18th, 2008 at 03:07 AM.