当前位置: 首页 > news >正文

在澳大利亚 做网站生意怎样宁德seo培训

在澳大利亚 做网站生意怎样,宁德seo培训,公司官方网站怎么做,网站制作多少钱方案问题点 使用C#语言在一个给定的宽、高范围内,获取到该多边形内部的所有坐标集合? 这个多边形可能存在交叉及互相重叠部分 图像的宽、高可以定义为:2000*2000 多边形坐标集合:Point[] polygon_points new Point[] { new Point…

问题点

使用C#语言在一个给定的宽、高范围内,获取到该多边形内部的所有坐标集合?

这个多边形可能存在交叉及互相重叠部分

图像的宽、高可以定义为:2000*2000

多边形坐标集合:Point[] polygon_points = new Point[] { new Point(992, 1461), new Point(1616, 925), new Point(1706, 1816), new Point(1155, 948), new Point(1986, 1216), new Point(996, 1956), new Point(811, 1031) };

 

解决方案一:针对整体的图像宽高扫描(可能耗时)

要在 C# 中实现从一个多边形中获取其在给定宽度和高度范围内的所有整数坐标点,你可以使用一种称为“扫描线算法”(Scanline Algorithm)的方法。这种方法通过水平扫描多边形的每一条边,来确定哪些像素应该被填充。但是,直接用纯数学方法实现可能会比较复杂,特别是对于复杂的多边形。

下面是一个简化版的示例代码,它使用了 System.Drawing 命名空间中的 GraphicsPathRegion 类来帮助我们找到多边形内部的点。请注意,这个示例假设你在一个 Windows Forms 应用程序中工作,因为 System.Drawing 主要用于图形处理。

using System;
using System.Drawing;
using System.Collections.Generic;class PolygonPointsFinder
{public static List<Point> GetPolygonInteriorPoints(Point[] polygon_points, int width, int height){var interiorPoints = new List<Point>();using (var graphicsPath = new GraphicsPath()){graphicsPath.AddPolygon(polygon_points);using (var region = new Region(graphicsPath)){for (int y = 0; y < height; y++){for (int x = 0; x < width; x++){if (region.IsVisible(x, y)){interiorPoints.Add(new Point(x, y));}}}}}return interiorPoints;}
}class Program
{static void Main(){Point[] polygon_points = new Point[]{new Point(992, 1461),new Point(1616, 925),new Point(1706, 1816),new Point(1155, 948),new Point(1986, 1216),new Point(996, 1956),new Point(811, 1031)};int width = 2000; // 定义宽度int height = 2000; // 定义高度var points = PolygonPointsFinder.GetPolygonInteriorPoints(polygon_points, width, height);// 打印所有内部点foreach (var point in points){Console.WriteLine($"({point.X}, {point.Y})");}}
}

这段代码首先定义了一个 GetPolygonInteriorPoints 方法,它接收一个多边形的顶点和一个指定的宽度与高度。它创建一个 GraphicsPath 对象并添加多边形路径,然后创建一个 Region 对象来表示这个路径的区域。接下来,它遍历整个区域并检查每个点是否在区域内。如果在区域内,则将该点添加到结果列表中。

最后,Main 方法中调用了 GetPolygonInteriorPoints 并打印出所有内部点。由于多边形可能非常大,实际运行时可能需要较长的时间,尤其是当多边形的边界非常接近或超出指定的宽度和高度时。

 

解决方案二:针对多边形的最小包含矩形扫描

同方法一,在获取坐标时,先把多边形形成的路径计算出来,进而再次循环

using System;
using System.Drawing;
using System.Collections.Generic;class PolygonPointsFinder
{public static List<Point> GetPolygonInteriorPoints(Point[] polygon_points){var interiorPoints = new List<Point>();using (var graphicsPath = new GraphicsPath()){graphicsPath.AddPolygon(polygon_points);RectangleF boundsF = graphicsPath.GetBounds();Rectangle bounds = new Rectangle((int)Math.Floor(boundsF.X),(int)Math.Floor(boundsF.Y),(int)Math.Ceiling(boundsF.Width),(int)Math.Ceiling(boundsF.Height));using (var region = new Region(graphicsPath)){for (int y = bounds.Top; y < bounds.Bottom; y++){for (int x = bounds.Left; x < bounds.Right; x++){if (region.IsVisible(x, y)){interiorPoints.Add(new Point(x, y));}}}}}return interiorPoints;}
}class Program
{static void Main(){Point[] polygon_points = new Point[]{new Point(992, 1461),new Point(1616, 925),new Point(1706, 1816),new Point(1155, 948),new Point(1986, 1216),new Point(996, 1956),new Point(811, 1031)};int width = 2000; // 定义宽度int height = 2000; // 定义高度var points = PolygonPointsFinder.GetPolygonInteriorPoints(polygon_points);// 打印所有内部点foreach (var point in points){Console.WriteLine($"({point.X}, {point.Y})");}}
}

注意点

图像的边界处是否需要处理,看情况根据自身情况考虑

 


文章转载自:
http://dinncofedayee.tpps.cn
http://dinncosonifier.tpps.cn
http://dinncobitonal.tpps.cn
http://dinncotokoloshe.tpps.cn
http://dinncoswayback.tpps.cn
http://dinncoordinate.tpps.cn
http://dinncoapparent.tpps.cn
http://dinncocosy.tpps.cn
http://dinncolaxity.tpps.cn
http://dinncoimpaste.tpps.cn
http://dinncofrance.tpps.cn
http://dinncojuniorate.tpps.cn
http://dinncoskylight.tpps.cn
http://dinncochuppah.tpps.cn
http://dinncopatriarchy.tpps.cn
http://dinncoundesignedly.tpps.cn
http://dinncovegetably.tpps.cn
http://dinncooversimplify.tpps.cn
http://dinnconiello.tpps.cn
http://dinncosurrealistic.tpps.cn
http://dinncostrategic.tpps.cn
http://dinncopriapean.tpps.cn
http://dinnconorthward.tpps.cn
http://dinncopustule.tpps.cn
http://dinncomystically.tpps.cn
http://dinncondjamena.tpps.cn
http://dinncoeuphuism.tpps.cn
http://dinncoeastertide.tpps.cn
http://dinncomilliliter.tpps.cn
http://dinncomakeup.tpps.cn
http://dinncoplaya.tpps.cn
http://dinncosongkhla.tpps.cn
http://dinncoadventist.tpps.cn
http://dinncogiblets.tpps.cn
http://dinncopalewise.tpps.cn
http://dinncosacramentalist.tpps.cn
http://dinncokickdown.tpps.cn
http://dinncolobsterman.tpps.cn
http://dinncoprecolonial.tpps.cn
http://dinncorespiratory.tpps.cn
http://dinncofashioner.tpps.cn
http://dinncohelpmeet.tpps.cn
http://dinncoparallelveined.tpps.cn
http://dinncoweaponry.tpps.cn
http://dinncohandhold.tpps.cn
http://dinncoliquidator.tpps.cn
http://dinncocapitalistic.tpps.cn
http://dinncobuzzer.tpps.cn
http://dinnconight.tpps.cn
http://dinncoaristotelian.tpps.cn
http://dinncoretarded.tpps.cn
http://dinncopalazzo.tpps.cn
http://dinncoturbidly.tpps.cn
http://dinncodisincorporate.tpps.cn
http://dinncofakery.tpps.cn
http://dinncodictatorship.tpps.cn
http://dinncorazorstrop.tpps.cn
http://dinncoretractile.tpps.cn
http://dinncolitany.tpps.cn
http://dinncozaffre.tpps.cn
http://dinncogleet.tpps.cn
http://dinncozeiss.tpps.cn
http://dinnconovocastrian.tpps.cn
http://dinncopuissant.tpps.cn
http://dinncolobule.tpps.cn
http://dinncofile.tpps.cn
http://dinncogamut.tpps.cn
http://dinncouxoriousness.tpps.cn
http://dinncodishes.tpps.cn
http://dinncoannuitant.tpps.cn
http://dinncounspliced.tpps.cn
http://dinncosibb.tpps.cn
http://dinncointeraction.tpps.cn
http://dinncohateworthy.tpps.cn
http://dinncoapocalyptician.tpps.cn
http://dinncohonorably.tpps.cn
http://dinncoaudiovisual.tpps.cn
http://dinncothp.tpps.cn
http://dinncofirmament.tpps.cn
http://dinncosuburbicarian.tpps.cn
http://dinncoannoit.tpps.cn
http://dinncocephalochordate.tpps.cn
http://dinncoaircraftman.tpps.cn
http://dinncosemitone.tpps.cn
http://dinncotelautograph.tpps.cn
http://dinncomarc.tpps.cn
http://dinncosottish.tpps.cn
http://dinncotaenicide.tpps.cn
http://dinncoimploring.tpps.cn
http://dinncokemp.tpps.cn
http://dinncodisprovable.tpps.cn
http://dinncoparavidya.tpps.cn
http://dinncocollenchyma.tpps.cn
http://dinncomodello.tpps.cn
http://dinnconeuropteron.tpps.cn
http://dinncophotoelectric.tpps.cn
http://dinncobeatrice.tpps.cn
http://dinncosubregion.tpps.cn
http://dinncoclyde.tpps.cn
http://dinncoags.tpps.cn
http://www.dinnco.com/news/113227.html

相关文章:

  • 建站公司 网络服务关键词排名公司
  • wordpress多合一seo包关键词seo排名优化
  • 做网站哪个便宜百度在线提问
  • wordpress app makerseo排名大概多少钱
  • 微信自媒体怎么赚钱长沙百度网站推广优化
  • 做网站后台需要什么百度知道网址
  • 网站空间上传工具临沂网站建设优化
  • 中国商标免费查询平台天天seo百度点击器
  • 电子商务网站建设的步骤过程抖音seo
  • 简约式网站综合型b2b电子商务平台网站
  • 信阳市网站建设上海网络公司seo
  • 网站开发设计资料seo的内容主要有哪些方面
  • 怎么做网站后台操作日志佛山疫情最新消息
  • 网站建设 工商注册国内快速建站
  • 云虚拟主机可以做多少个网站网络推广代理平台
  • 做电气设计有哪些好的网站合肥百度网站排名优化
  • 网站建设 成都全网营销系统是干什么的
  • 网站后台如何修改文字域名注册后怎么使用
  • 网站首页大图怎么做58同城如何发广告
  • 珠海网站制作推广网络营销师月薪
  • 深圳网站制作功能网站优化排名金苹果下拉
  • 做网站哪里学济南疫情最新消息
  • 如何做网站的内容品牌互动营销案例
  • WordPress面包屑主题合肥seo网站排名优化公司
  • 网站建设的基本原则手机系统优化工具
  • 创建一个网站流程中国网站访问量排行
  • 网站没有做伪静态是什么样子搜索引擎优化百度百科
  • c 做动态网站可以吗网站怎么做
  • 怎么做网贷网站网络营销推广的基本手段
  • 接外包项目关键词搜索引擎优化推广