区域没有意义 [英] Region not making sense

查看:70
本文介绍了区域没有意义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这对我来说意义不大...任何人都可以解释?

This doesn''t make much sense to me... anyone can explain?

Region x = new Region(new Rectangle(1, 1, 3, 3));
Console.WriteLine("" + x.IsVisible(new PointF(0f, 0f)));   // false
Console.WriteLine("" + x.IsVisible(new PointF(0.49f, 0.49f)));  // false
Console.WriteLine("" + x.IsVisible(new PointF(0.5f, 0.5f)));  // true!  ** unexpected, should start at 1,1
Console.WriteLine("" + x.IsVisible(new PointF(3.49f, 3.49f)));  //true
Console.WriteLine("" + x.IsVisible(new PointF(3.5f, 3.5f)));  // false!  ** unexpected, apparently right on the edge is out



为什么矩形从.5,.5开始清晰可见?我要求它为1,1 ...



Why is the rectangle seeminly starting at .5,.5? I asked it to be at 1,1...

推荐答案

我想可能是由于舍入(尽管通常舍入只是忽略了分形部分).另外,请尝试使用相同的类型(也许将PointF坐标转换为您的Rectangle坐标类型):将构造函数更改为
区域x =新区域(新矩形 F (1f,1f,3f,3f));
I guess it may be because of rounding (though usually rounding just ignores fractal part). Also, try using the same types (maybe PointF coordinates are being cast to your Rectangle coordinates type): change the constructor into
Region x = new Region(new RectangleF(1f, 1f, 3f, 3f));


这篇关于区域没有意义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆