i have one rectangule with these size(for example): 10X20(W,H)
how can i calculate the center (X,Y) of the rectangule?
thanks
Printable View
i have one rectangule with these size(for example): 10X20(W,H)
how can i calculate the center (X,Y) of the rectangule?
thanks
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.
my objective is transform the rectangle image in math circule cartegian(i'm sorry but i don't know the english right term)
thanks
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".Quote:
Originally Posted by NickThissen
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
Are you trying to convert between polar and rectangular? If not, more pictures overcome language barriers :)
i'm sorry but i don't hunderstand. the center of rectangule must be (0,0) in cartegianoQuote:
Originally Posted by jemidiah
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!!Quote:
Originally Posted by joaquim
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!
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
thanks to everyone, i found the solution....
heres my objective
thanks