简体   繁体   中英

RectangleF contains always returns false

I am using RectangleF.Contains(PointF) and it is always returning false.

Example Code:

  RectangleF bounds = RectangleF.FromLTRB(-180, 90, 180, -90);
  bounds.Contains(new PointF(0, 0);

I am trying to get this quadtree link library to work in Unity. I used the System.Drawing.dll from the Mono folder

The quadtree is going to be used to store latitude and longitude values.

Is it an issue with the bounds? Or is it something else?

With

bounds = RectangleF.FromLTRB(-180, 90, 180, -90);

You create an empty (or event "negative") rectangle. The y-coordinates work here like screen coordinates ascending from top to bottom.

So define the rectangle as

bounds = RectangleF.FromLTRB(-180, -90, 180, 90);

and bounds.Contains(new PointF(0, 0); will return true ;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM