# Help with maths...snif,sniff

fred fredricks

Greenhorn

Posts: 16

posted 13 years ago

hello!!!

ok, i have to do a maths problem sheet...and i am stuck...can u guys help me out?

thanks!!

e) give the outline of an efficient algorithm to test if a point is inside a rectangle.

f) how would you test whether two circles intersect

thanks!!!

ok, i have to do a maths problem sheet...and i am stuck...can u guys help me out?

thanks!!

e) give the outline of an efficient algorithm to test if a point is inside a rectangle.

f) how would you test whether two circles intersect

thanks!!!

Jason Menard

Sheriff

Posts: 6450

Bhau Mhatre

Ranch Hand

Posts: 199

HS Thomas

Ranch Hand

Posts: 3404

posted 13 years ago

Given the point's co-ordinates x,y

If (x >= Xa) and (x <= Xb)

and if (y >= Ya) and (y <= Yb) then point x,y is inside the rectangle,

where the co-ordinates of the four points are Xa,Ya ; Xa,Yb ; Xb,Ya ; Xb,Yb.

Xa <= x >= Xb and Ya <= y >= Yb

I think that works ,as long as you are given the points and rectangles co-ordinates.

[ August 25, 2003: Message edited by: HS Thomas ]

give the outline of an efficient algorithm to test if a point is inside a rectangle.

Given the point's co-ordinates x,y

If (x >= Xa) and (x <= Xb)

and if (y >= Ya) and (y <= Yb) then point x,y is inside the rectangle,

where the co-ordinates of the four points are Xa,Ya ; Xa,Yb ; Xb,Ya ; Xb,Yb.

**Or , more concisely**

Xa <= x >= Xb and Ya <= y >= Yb

I think that works ,as long as you are given the points and rectangles co-ordinates.

[ August 25, 2003: Message edited by: HS Thomas ]

Mark Herschberg

Sheriff

Posts: 6037

fred fredricks

Greenhorn

Posts: 16

Mark Herschberg

Sheriff

Posts: 6037

posted 13 years ago

Some people try to get homework problems done for them by posting on this site. You were upfront about it.

I just wanted to make it clear to other posters that they shouldn't solve the problems outright, but rather give you advice and suggestions. I think that is fine.

I'm not sure if this is quite the right forum for it, in that this forum is for problem discussion, and we would have to minimize discussion in order to not do your work for you.

--Mark

I just wanted to make it clear to other posters that they shouldn't solve the problems outright, but rather give you advice and suggestions. I think that is fine.

I'm not sure if this is quite the right forum for it, in that this forum is for problem discussion, and we would have to minimize discussion in order to not do your work for you.

--Mark