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

怎么创建免费网站微网站建设包含哪些内容

怎么创建免费网站,微网站建设包含哪些内容,郴州市12345官网,赣州品牌网站建设(1)已知2D下,新坐标系的原点、X轴方向向量、Y轴方向向量在原始坐标系下的表示,求原始坐标系中直线,在新坐标系下的直线方程;(2)求直线与2D包围盒的交点,可能有0、1或2个交…

(1)已知2D下,新坐标系的原点、X轴方向向量、Y轴方向向量在原始坐标系下的表示,求原始坐标系中直线ax+by+c=0,在新坐标系下的直线方程;

(2)求直线与2D包围盒的交点,可能有0、1或2个交点;

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
//using System.Windows.Forms;namespace DTSAlgorithm
{class CoordinateTransform{// 定义一个方法来计算变换矩阵public static double[,] CalculateTransformationMatrix(double Ox, double Oy, double ux, double uy, double vx, double vy){// 创建一个3x3的变换矩阵double[,] transformationMatrix = new double[3, 3];// 设置矩阵的元素transformationMatrix[0, 0] = ux; // 新坐标系x轴方向向量的x分量transformationMatrix[0, 1] = uy; // 新坐标系y轴方向向量的x分量transformationMatrix[0, 2] = -ux * Ox - uy * Oy; // 新坐标系原点的x坐标transformationMatrix[1, 0] = vx; // 新坐标系x轴方向向量的y分量transformationMatrix[1, 1] = vy; // 新坐标系y轴方向向量的y分量transformationMatrix[1, 2] = -vx * Ox - vy * Oy; // 新坐标系原点的y坐标transformationMatrix[2, 0] = 0;  // 齐次坐标部分transformationMatrix[2, 1] = 0;transformationMatrix[2, 2] = 1;return transformationMatrix;}// 打印矩阵的方法public static void PrintMatrix(double[,] matrix){for (int i = 0; i < matrix.GetLength(0); i++){for (int j = 0; j < matrix.GetLength(1); j++){Console.Write(matrix[i, j] + "\t");}Console.WriteLine();}}}public struct BoundingBox{public double XMin { get; }public double XMax { get; }public double YMin { get; }public double YMax { get; }public BoundingBox(double xmin, double xmax, double ymin, double ymax){XMin = xmin;XMax = xmax;YMin = ymin;YMax = ymax;}public override string ToString() =>$"X:[{XMin}, {XMax}], Y:[{YMin}, {YMax}]";}public class BoundingBoxCalculator{public static BoundingBox GetTransformedBoundingBox(List<PointF> originalPoints,double[,] transformMatrix){if (originalPoints == null || originalPoints.Count == 0)throw new ArgumentException("点集不能为空");if (transformMatrix.GetLength(0) != 3 || transformMatrix.GetLength(1) != 3)throw new ArgumentException("变换矩阵必须是3x3矩阵");double xmin = double.MaxValue, xmax = double.MinValue;double ymin = double.MaxValue, ymax = double.MinValue;foreach (var point in originalPoints){// 应用变换矩阵 (齐次坐标变换)double x = transformMatrix[0, 0] * point.X +transformMatrix[0, 1] * point.Y +transformMatrix[0, 2];double y = transformMatrix[1, 0] * point.X +transformMatrix[1, 1] * point.Y +transformMatrix[1, 2];// 透视除法(如果是仿射变换,则w=1)double w = transformMatrix[2, 0] * point.X +transformMatrix[2, 1] * point.Y +transformMatrix[2, 2];if (Math.Abs(w) > 1e-6) // 避免除以零{x /= w;y /= w;}// 更新边界xmin = Math.Min(xmin, x);xmax = Math.Max(xmax, x);ymin = Math.Min(ymin, y);ymax = Math.Max(ymax, y);}return new BoundingBox(xmin, xmax, ymin, ymax);}}public class LineTransformer{/// <summary>/// 计算变换后的直线方程系数/// </summary>/// <param name="a">原始直线方程ax+by+c=0的a系数</param>/// <param name="b">原始直线方程ax+by+c=0的b系数</param>/// <param name="c">原始直线方程ax+by+c=0的c系数</param>/// <param name="transformMatrix">3x3齐次变换矩阵(仿射变换)</param>/// <returns>新坐标系下的直线系数(a', b', c')</returns>public static (double a, double b, double c) TransformLineEquation(double a, double b, double c,double[,] transformMatrix){// 验证矩阵尺寸if (transformMatrix.GetLength(0) != 3 || transformMatrix.GetLength(1) != 3)throw new ArgumentException("变换矩阵必须是3x3矩阵");// 计算变换矩阵的逆矩阵(用于直线变换)if (!InvertMatrix(transformMatrix, out double[,] invMatrix))throw new ArgumentException("变换矩阵不可逆");// 直线变换公式:新系数 = 原始系数 * 逆变换矩阵double a_new = a * invMatrix[0, 0] + b * invMatrix[1, 0];double b_new = a * invMatrix[0, 1] + b * invMatrix[1, 1];double c_new = a * invMatrix[0, 2] + b * invMatrix[1, 2] + c;return (a_new, b_new, c_new);}/// <summary>/// 3x3矩阵求逆(简化版,适用于仿射变换)/// </summary>private static bool InvertMatrix(double[,] matrix, out double[,] inverse){inverse = new double[3, 3];double det = matrix[0, 0] * (matrix[1, 1] * matrix[2, 2] - matrix[1, 2] * matrix[2, 1]) -matrix[0, 1] * (matrix[1, 0] * matrix[2, 2] - matrix[1, 2] * matrix[2, 0]) +matrix[0, 2] * (matrix[1, 0] * matrix[2, 1] - matrix[1, 1] * matrix[2, 0]);if (Math.Abs(det) < 1e-6f) return false;double invDet = 1.0f / det;inverse[0, 0] = (matrix[1, 1] * matrix[2, 2] - matrix[1, 2] * matrix[2, 1]) * invDet;inverse[0, 1] = (matrix[0, 2] * matrix[2, 1] - matrix[0, 1] * matrix[2, 2]) * invDet;inverse[0, 2] = (matrix[0, 1] * matrix[1, 2] - matrix[0, 2] * matrix[1, 1]) * invDet;inverse[1, 0] = (matrix[1, 2] * matrix[2, 0] - matrix[1, 0] * matrix[2, 2]) * invDet;inverse[1, 1] = (matrix[0, 0] * matrix[2, 2] - matrix[0, 2] * matrix[2, 0]) * invDet;inverse[1, 2] = (matrix[0, 2] * matrix[1, 0] - matrix[0, 0] * matrix[1, 2]) * invDet;inverse[2, 0] = (matrix[1, 0] * matrix[2, 1] - matrix[1, 1] * matrix[2, 0]) * invDet;inverse[2, 1] = (matrix[0, 1] * matrix[2, 0] - matrix[0, 0] * matrix[2, 1]) * invDet;inverse[2, 2] = (matrix[0, 0] * matrix[1, 1] - matrix[0, 1] * matrix[1, 0]) * invDet;return true;}}public class LineSegmentCalculator{public static Tuple<PointF, PointF> GetLineSegmentInBoundingBox(double a, double b, double c, BoundingBox box){double xmin = box.XMin;double xmax = box.XMax;double ymin = box.YMin;double ymax = box.YMax;List<PointF> intersections = new List<PointF>();// 检查直线是否与矩形的四条边相交// 1. 左边界 (x = xmin)if (b != 0) // 避免垂直于y轴的直线{double y = (-a * xmin - c) / b;if (y >= ymin && y <= ymax)intersections.Add(new PointF(xmin, y));}// 2. 右边界 (x = xmax)if (b != 0){double y = (-a * xmax - c) / b;if (y >= ymin && y <= ymax)intersections.Add(new PointF(xmax, y));}// 3. 下边界 (y = ymin)if (a != 0) // 避免垂直于x轴的直线{double x = (-b * ymin - c) / a;if (x >= xmin && x <= xmax)intersections.Add(new PointF(x, ymin));}// 4. 上边界 (y = ymax)if (a != 0){double x = (-b * ymax - c) / a;if (x >= xmin && x <= xmax)intersections.Add(new PointF(x, ymax));}// 去重并验证交点数量intersections = RemoveDuplicates(intersections);if (intersections.Count == 2){return new Tuple<PointF, PointF>(intersections[0], intersections[1]);}else if (intersections.Count == 1){// 直线与矩形相切(仅一个交点)return new Tuple<PointF, PointF>(intersections[0], intersections[0]);}else{// 无交点(直线完全在矩形外或矩形退化为点)return null;}}private static List<PointF> RemoveDuplicates(List<PointF> points){List<PointF> uniquePoints = new List<PointF>();foreach (var point in points){bool isDuplicate = false;foreach (var uniquePoint in uniquePoints){if (Math.Abs(point.X - uniquePoint.X) < 1e-6 &&Math.Abs(point.Y - uniquePoint.Y) < 1e-6){isDuplicate = true;break;}}if (!isDuplicate)uniquePoints.Add(point);}return uniquePoints;}}internal class Program{[STAThread]private static void Main(){string filePath = "rotate.csv";var points = new List<PointF>();using (var reader = new StreamReader(filePath)){while (!reader.EndOfStream){string line = reader.ReadLine();string[] values = line.Split(';');if (values.Length == 3 &&double.TryParse(values[0], out double x) &&double.TryParse(values[1], out double y) &&double.TryParse(values[2], out double z)){points.Add(new PointF(x, y));}else{Console.WriteLine($"跳过无效行: {line}");}}}double ux = 0.935277;double uy = -0.353918;double vx = 0.353918;double vy = 0.935277;double Ox = -1.274;double Oy = 9.878;double[,] transformationMatrix = CoordinateTransform.CalculateTransformationMatrix(Ox, Oy, ux, uy, vx, vy);BoundingBox box = BoundingBoxCalculator.GetTransformedBoundingBox(points, transformationMatrix);double outerline_A = 0.354;double outerline_B = 0.935;double outerline_C = -8.788;(double a, double b, double c)  = LineTransformer.TransformLineEquation(outerline_A, outerline_B, outerline_C, transformationMatrix);Tuple<PointF, PointF> result = LineSegmentCalculator.GetLineSegmentInBoundingBox(a, b, c, box);}}
}


文章转载自:

http://8IiVUzlM.ctswj.cn
http://UPYE7dMU.ctswj.cn
http://BLdVS1ci.ctswj.cn
http://yoHscg0e.ctswj.cn
http://xfgbV3Oc.ctswj.cn
http://ZQiD9vne.ctswj.cn
http://oW65RKj5.ctswj.cn
http://SO4Xqb2C.ctswj.cn
http://4RJ1g9XP.ctswj.cn
http://r5wuPhlM.ctswj.cn
http://JTsq3Y7T.ctswj.cn
http://exoiXuXX.ctswj.cn
http://LXLgR0ZS.ctswj.cn
http://rMvQi22Z.ctswj.cn
http://eL1aWqjo.ctswj.cn
http://ib5tW36S.ctswj.cn
http://GKGpq7kA.ctswj.cn
http://y3XjZnWk.ctswj.cn
http://E7yqq0ak.ctswj.cn
http://NbI5GsOc.ctswj.cn
http://R8HUJ2c7.ctswj.cn
http://hXWoe3yV.ctswj.cn
http://9H7CmqXV.ctswj.cn
http://64jpnPeY.ctswj.cn
http://O1fYIg31.ctswj.cn
http://YJNgt2Nt.ctswj.cn
http://nTFINhja.ctswj.cn
http://ZlZ0EAZV.ctswj.cn
http://q9rGZNw0.ctswj.cn
http://lNacJdmn.ctswj.cn
http://www.dtcms.com/wzjs/645307.html

相关文章:

  • 有哪些做ae小动效的网站资源网站的建设
  • 可以直接进入网站的正能量群晖nas做网站
  • 公司网站首页大图怎么做新网站如何做排名
  • 在哪做网站专业营销型网站建设原则
  • 千图网解析网站怎么做阅读网站建设规划书
  • 400选号网站源码教育类网站策划书
  • 手机怎么创建自己的网站平台建筑材料价格信息网
  • 企业网站建设预算湖南人文科技学院在哪
  • 建网站系统能换吗网站开发项目个人总结
  • 西安免费做网站多少钱辽宁建设工程信息网签章
  • 网站怎么做才被收录快郑州市建筑材料信息价
  • 石家庄网站空间建网站卖东西
  • 个人音乐网站源码阿里云装wordpress慢
  • 定西网站建设公司什么是百度搜索推广
  • 怎样让自己做的网站被百度收录网站平台结构
  • 网站建设相关语言网站的超级链接怎么做
  • 郑州定制网站国内最新新闻热点事件
  • 湖南省城乡建设勘测院 网站ui设计师可以做到多少岁
  • 跟公司产品做网站布吉网站建设哪家服务周到
  • 房产信息网站西宁互联网公司
  • 如何建设一免费的网站高端品牌粉碎机
  • 哈尔滨悦创网络科技网站开发一个公司可以做两个网站不
  • 网站企业快速备案室内设计主要学什么课程
  • 网站预算表怎么做如何接推广的单子
  • 运城 网站 建设 招聘重庆市建设局网站
  • 网站规划建设与管理维护的论文光通信网站模板
  • 个人网站报价制作网站的步骤有哪些
  • 渑池县建设局网站南京响应式网站建设
  • 网站公司制作网站新闻不添加关键词超链接对优化有影响吗
  • 郑州官网网络营销外包成都网站优化及推广