Click to See Complete Forum and Search --> : [RESOLVED] how calculate the center of a rectangule?
joaquim
Jun 20th, 2008, 02:41 PM
i have one rectangule with these size(for example): 10X20(W,H)
how can i calculate the center (X,Y) of the rectangule?
thanks
NickThissen
Jun 20th, 2008, 03:55 PM
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.
joaquim
Jun 20th, 2008, 04:02 PM
my objective is transform the rectangle image in math circule cartegian(i'm sorry but i don't know the english right term)
thanks
NickThissen
Jun 20th, 2008, 04:12 PM
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)?
joaquim
Jun 21st, 2008, 12:50 AM
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
jemidiah
Jun 21st, 2008, 06:19 PM
Are you trying to convert between polar and rectangular? If not, more pictures overcome language barriers :)
joaquim
Jun 22nd, 2008, 03:49 AM
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 cartegiano
opus
Jun 24th, 2008, 09:09 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!
EvoRob
Jul 18th, 2008, 03:04 AM
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
joaquim
Aug 5th, 2008, 03:15 PM
thanks to everyone, i found the solution....
heres my objective (http://www.vbforums.com/showthread.php?t=534230)
thanks
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.