You are not logged in.

- Topics: Active | Unanswered

**tina123****Member**- Registered: 2012-04-29
- Posts: 83

i have a rectangle with height = 123 and width = 92. also i have central location x ,y = 47 , 62 .

I can find the mid point of width and height of rectangle .

but i want to get location x ,y of mid point of width or height of rectangle .How can i get that .

Can any one please tell me mathematically .

thanks

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 104,789

Hi tina123;

In order to get the x,y coordinates of your rectangle it would have to located along the xy axis otherwise the center point of it will be different for each rectangle.

See the drawing below.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**

Offline

**tina123****Member**- Registered: 2012-04-29
- Posts: 83

Well, we can find central location of a rectangle .

let say we have x,y initiail corner of rectangle is 1,1 . width and height of rectangle is 92 and 23 .

so cX = x + width/2 , cy =y+ height /2

that will give u central location of rectangle .

but how can we get location of mid point of width or height ?

*Last edited by tina123 (2012-09-19 11:38:02)*

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 104,789

Hi;

To get the midpoint of a side you just add the coordinates and divide by 2. Same as for a line.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**

Offline

**tina123****Member**- Registered: 2012-04-29
- Posts: 83

bobbym wrote:

Hi;

To get the midpoint of a side you just add the coordinates and divide by 2. Same as for a line.

i know the way to get the mid point . mid point will be single value .

i want mid point location in x , y .

How can we get that ?

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 104,789

Hi;

Do you want the mid point of a side or of the rectangle?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**

Offline

**tina123****Member**- Registered: 2012-04-29
- Posts: 83

bobbym wrote:

Hi;

Do you want the mid point of a side or of the rectangle?

yes , i mid point(int form of x ,y ) of a side of rectangle .

thanks

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 104,789

Since the sides of a rectangle are either horizontal or vertical lines you do this.

For a horizontal side with coordinates (x1,y1) and (x2,y2) the midpoint is

For a vertical side with coordinates (x1,y1) and (x2,y2) the midpoint is

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**

Offline

**tina123****Member**- Registered: 2012-04-29
- Posts: 83

Hy Dear Bobby,

Is that correct way to get the location in x,y of mid point of width and height ?

please check it : http://i1069.photobucket.com/albums/u472/tina12354/recTest_zps8f233dc8.png

Thanks

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 104,789

Hi tina123;

Those formulas are the correct way to get the midpoint ( the red marks ) of a side of a rectangle when you have the (x,y) coordinates of the vertices of the side.

Try it on one.

Do you need a little more to understand it?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**

Offline