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

网站开发用C今天的军事新闻

网站开发用C,今天的军事新闻,做网站开发的商标注册多少类,php网站整合discuz1.判断点是否在一群点内部 要判断一个点是否在一个由多个点围成的多边形内部#xff08;例如一圈点#xff09;#xff0c;可以使用射线法#xff08;Ray Casting Algorithm#xff09;来实现。以下是一个简单的 C# 实现示例 using System;public class Point {public d…1.判断点是否在一群点内部 要判断一个点是否在一个由多个点围成的多边形内部例如一圈点可以使用射线法Ray Casting Algorithm来实现。以下是一个简单的 C# 实现示例 using System;public class Point {public double X { get; set; }public double Y { get; set; }public Point(double x, double y){X x;Y y;} }public class Program {public static bool IsPointInPolygon(Point testPoint, Point[] polygon){bool inside false;int count polygon.Length;for (int i 0, j count - 1; i count; j i){if (((polygon[i].Y testPoint.Y) ! (polygon[j].Y testPoint.Y)) (testPoint.X (polygon[j].X - polygon[i].X) * (testPoint.Y - polygon[i].Y) / (polygon[j].Y - polygon[i].Y) polygon[i].X)){inside !inside;}}return inside;}public static void Main(){Point[] polygon new Point[]{new Point(0, 0),new Point(0, 4),new Point(4, 4),new Point(4, 0)};Point testPoint new Point(2, 2);bool isInside IsPointInPolygon(testPoint, polygon);Console.WriteLine($Point ({testPoint.X}, {testPoint.Y}) is inside the polygon: {isInside});} }2.判断点在直线左侧还是右侧 要在C#中判断一个点在一条直线的左侧还是右侧可以使用点与直线方程的方法。具体来说对于直线上的两个点A和B以及要测试的点P可以通过计算点P相对于直线AB的位置来确定其是否在直线的左侧还是右侧。 以下是一个简单的C#示例 using System;public class Point {public double X { get; set; }public double Y { get; set; }public Point(double x, double y){X x;Y y;} }public class Line {public Point A { get; set; }public Point B { get; set; }public Line(Point a, Point b){A a;B b;}// 计算点P相对于直线AB的位置public double PointRelativeToLine(Point P){return (B.X - A.X) * (P.Y - A.Y) - (B.Y - A.Y) * (P.X - A.X);} }public class Program {public static void Main(){Point pointA new Point(1, 1);Point pointB new Point(4, 5);Line lineAB new Line(pointA, pointB);Point testPoint new Point(2, 3);double position lineAB.PointRelativeToLine(testPoint);if (position 0){Console.WriteLine(Point is on the left side of the line.);}else if (position 0){Console.WriteLine(Point is on the right side of the line.);}else{Console.WriteLine(Point is on the line.);}} } 3.判断两条直线的交点  要判断两条直线的交点可以使用直线的参数方程来求解。两条直线的参数方程可以表示为 直线1 (x x_1 t_1 \cdot (x_2 - x_1)) 和 (y y_1 t_1 \cdot (y_2 - y_1)) 直线2 (x x_3 t_2 \cdot (x_4 - x_3)) 和 (y y_3 t_2 \cdot (y_4 - y_3)) 要求两条直线的交点需要解方程组即求解 (t_1) 和 (t_2)然后代入其中一个直线的参数方程中即可求得交点的坐标。 以下是一个C#示例 using System;public class Point {public double X { get; set; }public double Y { get; set; }public Point(double x, double y){X x;Y y;} }public class Line {public Point A { get; set; }public Point B { get; set; }public Line(Point a, Point b){A a;B b;}// 计算两条直线的交点public Point IntersectionPoint(Line otherLine){double x1 A.X;double y1 A.Y;double x2 B.X;double y2 B.Y;double x3 otherLine.A.X;double y3 otherLine.A.Y;double x4 otherLine.B.X;double y4 otherLine.B.Y;double denominator (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);if (denominator 0){throw new InvalidOperationException(Lines are parallel. No intersection point exists.);}double t1 ((x1 - x3) * (y3 - y4) - (y1 - y3) * (x3 - x4)) / denominator;double t2 -((x1 - x2) * (y1 - y3) - (y1 - y2) * (x1 - x3)) / denominator;double intersectionX x1 t1 * (x2 - x1);double intersectionY y1 t1 * (y2 - y1);return new Point(intersectionX, intersectionY);} }public class Program {public static void Main(){Point pointA1 new Point(1, 1);Point pointB1 new Point(4, 5);Line line1 new Line(pointA1, pointB1);Point pointA2 new Point(2, 3);Point pointB2 new Point(6, 1);Line line2 new Line(pointA2, pointB2);try{Point intersectionPoint line1.IntersectionPoint(line2);Console.WriteLine($Intersection Point: ({intersectionPoint.X}, {intersectionPoint.Y}));}catch (InvalidOperationException ex){Console.WriteLine(ex.Message);}} }
http://www.dnsts.com.cn/news/56924.html

相关文章:

  • 今标 网站建设网站系统问题解决措施
  • 湖北省建设用地预审网站群晖frp 外网访问wordpress
  • 江苏靖江苏源建设有限公司招标网站做电商网站需要多少时间
  • php网站怎么缓存宜昌网络推广公司
  • 广州市专业网站设计wordpress 打不开主题
  • php网站建设安装环境大连哪个区最好
  • 如何开始做网站wd网址怎么推广
  • 网页 开发淄博seo排名
  • 建立网站费用表中国最强十大国企
  • 个人网站备案幕布成都网站建设公司 四川冠辰科技
  • 简单个人网站欣赏wordpress 放弃react
  • h5网站制作工具游戏网官网
  • 实验仪器销信应做何网站wordpress多语言包
  • 做女装的网站南沙营销型网站建设
  • 郑州个人网站制作公司ppt模板免费下载素材图片
  • 如何制作网站主页wordpress英文版切换中文
  • 国内网站建设联系电话设计排版优秀网站
  • 大连网站建设 选领超科技wordpress懒加载插件
  • 广州网站开发十度网络最好wordpress的搭建环境
  • 象山住房和城乡建设局网站做网站得花多钱
  • 做报名统计的网站wordpress返回仪表盘
  • 2021中国十大软件公司排名seo官网
  • 中原区建设局网站链接网站logo
  • 尧都区建设厅官方网站数字化营销怎么做
  • 如何注册网站免费注册wordpress 发布文章 自定义栏目
  • 中学教材数字化学习资源的建设——教材配套网站的设计及发展趋势专业网站建设公司推荐
  • 网站建设与管理设计蚌埠seo
  • 网站如何做优化网站如何做提交的报名表
  • 如何判断网站做的关键词怎么查网站空间在哪里
  • 可以做网站首页的图片素材网络优化策划书