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

景翔物流网站建设公司做门户网站多少钱

景翔物流网站建设公司,做门户网站多少钱,深圳免费网站制作哪个好,上海高端网站建设服务公核心原理分析 1. 寻找全局最低点 要将曲线平移到原点,首先需要确定曲线的最低点。对于由多段圆弧组成的曲线,最低点可能出现在以下位置: 某个圆弧段的起点或终点某个圆弧段的最低点(当圆弧包含该点时) 对于每个圆弧…

核心原理分析

1. 寻找全局最低点

要将曲线平移到原点,首先需要确定曲线的最低点。对于由多段圆弧组成的曲线,最低点可能出现在以下位置:

  • 某个圆弧段的起点或终点
  • 某个圆弧段的最低点(当圆弧包含该点时)

对于每个圆弧段,需要判断其是否包含最低点,这取决于圆弧的方向和覆盖的角度范围。

2. 计算平移向量

一旦找到全局最低点 ( m i n x , m i n y ) (min_x, min_y) (minx,miny),平移向量即为 ( − m i n x , − m i n y ) (-min_x, -min_y) (minx,miny),将该向量应用到曲线的所有点上,即可将最低点移动到原点。

3. 应用平移

对每个圆弧段的起点、终点和圆心应用平移向量,更新它们的坐标。

公式推导

圆弧最低点判断

对于一个圆弧段,圆心为 C ( C x , C y ) C(C_x, C_y) C(Cx,Cy),半径为 r r r,起点为 S ( S x , S y ) S(S_x, S_y) S(Sx,Sy),终点为 E ( E x , E y ) E(E_x, E_y) E(Ex,Ey)

  1. 计算角度范围
    • 起点和终点相对于圆心的角度:
      θ S = arctan ⁡ 2 ( S y − C y , S x − C x ) \theta_S = \arctan2(S_y - C_y, S_x - C_x) θS=arctan2(SyCy,SxCx)

θ E = arctan ⁡ 2 ( E y − C y , E x − C x ) \theta_E = \arctan2(E_y - C_y, E_x - C_x) θE=arctan2(EyCy,ExCx)

  • 通过叉积判断圆弧方向(逆时针或顺时针):
    cross = ( S x − C x ) ( E y − C y ) − ( S y − C y ) ( E x − C x ) \text{cross} = (S_x - C_x)(E_y - C_y) - (S_y - C_y)(E_x - C_x) cross=(SxCx)(EyCy)(SyCy)(ExCx)
    cross > 0 \text{cross} > 0 cross>0,则为逆时针方向;否则为顺时针方向。
  1. 判断270度是否在角度范围内

    • 对于逆时针圆弧:
      • θ S ≤ θ E \theta_S \leq \theta_E θSθE,范围为 [ θ S , θ E ] [\theta_S, \theta_E] [θS,θE]
      • 否则,范围为 [ θ S , θ E + 2 π ] [\theta_S, \theta_E + 2\pi] [θS,θE+2π]
    • 对于顺时针圆弧:
      • θ S ≥ θ E \theta_S \geq \theta_E θSθE,范围为 [ θ E , θ S ] [\theta_E, \theta_S] [θE,θS]
      • 否则,范围为 [ θ E , θ S + 2 π ] [\theta_E, \theta_S + 2\pi] [θE,θS+2π]
    • 检查 3 π / 2 3\pi/2 3π/2(270度)是否在上述范围内。
  2. 确定最低点

    • 若270度在范围内,最低点为圆心下方的点 ( C x , C y − r ) (C_x, C_y - r) (Cx,Cyr)
    • 否则,最低点为起点或终点中y坐标较小的那个。

平移向量计算

找到全局最低点 ( m i n x , m i n y ) (min_x, min_y) (minx,miny) 后,平移向量为:
translation = ( − m i n x , − m i n y , 0 ) \text{translation} = (-min_x, -min_y, 0) translation=(minx,miny,0)

完整代码实现

#include <vector>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <cmath>
#include <limits>struct ArcSegment {gp_Pnt start;gp_Dir startTangent;gp_Pnt end;gp_Dir endTangent;gp_Pnt center;double radius;
};// 查找所有圆弧段中的全局最低点
gp_Pnt findGlobalLowestPoint(const std::vector<ArcSegment>& arcs) {double min_y = std::numeric_limits<double>::max();gp_Pnt lowest_point;for (const auto& arc : arcs) {// 处理直线段(半径接近0的情况)if (arc.radius < 1e-6) {const gp_Pnt& candidate = (arc.start.Y() < arc.end.Y()) ? arc.start : arc.end;if (candidate.Y() < min_y) {min_y = candidate.Y();lowest_point = candidate;}continue;}// 提取圆弧几何参数const double Cx = arc.center.X();const double Cy = arc.center.Y();const double r = arc.radius;const double Sy = arc.start.Y();const double Ey = arc.end.Y();// 计算起点和终点相对于圆心的角度(弧度)const double theta_S = atan2(arc.start.Y() - Cy, arc.start.X() - Cx);const double theta_E = atan2(arc.end.Y() - Cy, arc.end.X() - Cx);// 通过叉积判断圆弧方向(逆时针/顺时针)const double cross = (arc.start.X() - Cx) * (arc.end.Y() - Cy) - (arc.start.Y() - Cy) * (arc.end.X() - Cx);const bool is_ccw = (cross > 0);  // 逆时针方向// 标准化角度到[0, 2π)double theta_start = fmod(theta_S + 2*M_PI, 2*M_PI);double theta_end = fmod(theta_E + 2*M_PI, 2*M_PI);const double theta_270 = 3*M_PI/2;  // 270度对应弧度// 判断圆弧是否包含最低点(圆心正下方)bool contains_270 = false;if (is_ccw) {if (theta_start <= theta_end) {contains_270 = (theta_start <= theta_270) && (theta_270 <= theta_end);} else {contains_270 = (theta_270 >= theta_start) || (theta_270 <= theta_end);}} else {if (theta_start >= theta_end) {contains_270 = (theta_end <= theta_270) && (theta_270 <= theta_start);} else {contains_270 = (theta_270 >= theta_start) || (theta_270 <= theta_end);}}// 确定本段最低点double current_min_y = std::min(Sy, Ey);gp_Pnt current_lowest = (Sy < Ey) ? arc.start : arc.end;// 如果包含圆心正下方点则参与比较if (contains_270) {const double cy_low = Cy - r;if (cy_low < current_min_y) {current_min_y = cy_low;current_lowest = gp_Pnt(Cx, cy_low, 0.0);}}// 更新全局最低点if (current_min_y < min_y) {min_y = current_min_y;lowest_point = current_lowest;}}return lowest_point;
}// 平移所有圆弧段使最低点位于原点
std::vector<ArcSegment> translateArcsToOrigin(const std::vector<ArcSegment>& arcs) {// 找到全局最低点const gp_Pnt lowest = findGlobalLowestPoint(arcs);// 计算平移向量const gp_Vec translation(-lowest.X(), -lowest.Y(), 0);// 平移所有圆弧几何元素std::vector<ArcSegment> translated;for (const auto& arc : arcs) {ArcSegment newArc = arc;// 平移起点newArc.start.Translate(translation);// 平移终点newArc.end.Translate(translation);// 平移圆心newArc.center.Translate(translation);translated.push_back(newArc);}return translated;
}/* 使用示例
int main() {std::vector<ArcSegment> inputArcs; // 输入的多段圆弧数据std::vector<ArcSegment> outputArcs = translateArcsToOrigin(inputArcs);// outputArcs中的圆弧最低点已位于坐标原点return 0;
}
*/

代码说明

  1. 寻找全局最低点

    • 遍历每个圆弧段,计算其可能的最低点,包括起点、终点和圆心下方的点(如果圆弧包含该点)。
    • 比较所有圆弧段的最低点,找到全局最低点。
  2. 计算平移向量

    • 根据全局最低点的坐标,计算将该点移动到原点所需的平移向量。
  3. 应用平移

    • 对每个圆弧段的起点、终点和圆心应用平移向量,更新它们的坐标。

该实现确保了多段圆弧构成的连续曲线能够准确地平移到原点,同时保留了曲线的几何特性和连续性。


文章转载自:

http://VZAbZK3y.yjknk.cn
http://bt3N5ekK.yjknk.cn
http://R2AaaoMl.yjknk.cn
http://xRC0jcw0.yjknk.cn
http://W6Nn48ex.yjknk.cn
http://gyLEyJSy.yjknk.cn
http://lVKjSYRz.yjknk.cn
http://LJSWrZ0N.yjknk.cn
http://zhOJ2EkI.yjknk.cn
http://wzZcDEqM.yjknk.cn
http://DJc9rM3G.yjknk.cn
http://HX8hdtGv.yjknk.cn
http://4XfpgSck.yjknk.cn
http://jPudg4aU.yjknk.cn
http://3xauvrIz.yjknk.cn
http://8aV36yeA.yjknk.cn
http://WC9b4Tc1.yjknk.cn
http://MlqGmD3F.yjknk.cn
http://VnxxNDlo.yjknk.cn
http://qwmiH5WT.yjknk.cn
http://PbxodrmI.yjknk.cn
http://rJ4SqG8Z.yjknk.cn
http://r8wyjDL9.yjknk.cn
http://FLxW7dHJ.yjknk.cn
http://2BaSGAXn.yjknk.cn
http://bYMtSxKN.yjknk.cn
http://RpMwxtKF.yjknk.cn
http://vTjoIelF.yjknk.cn
http://9T52pzQr.yjknk.cn
http://AwaWmRrx.yjknk.cn
http://www.dtcms.com/wzjs/678855.html

相关文章:

  • 网站建设现状调查研究wordpress英文版下载地址
  • wordpress模板网站软件设计师中级
  • 能够做数据地图的网站网站模板尺寸
  • 网站制作好学吗交通网上服务平台
  • 首都开发公司东莞seo建站咨询
  • 网站建设及推广费用什么网站做电脑系统好
  • houzz室内设计wordpress配置搜索引擎优化
  • 专门做图标的网站深圳做网站推广
  • 网站建设 引导沧州网站建设熊掌号
  • 网站开发项目人员安排wordpress浮动视频
  • wordpress全站源码wordpress主循环
  • wordpress 页面 模板seo咨询师
  • 灌阳县建设局门户网站怎么看网站开发的好坏
  • 荆州房地产网站建设免费软件 全免费
  • 安阳网站优化360免费wifi无法在win10下正常运行
  • 网站规划对网站建设起到好的建网站的书籍
  • 株洲网站开发公司大数据平台设计
  • 新网站建设方案长沙网站优化seo
  • 自助建站怎么实现的广州百度提升优化
  • 湖北优化网站建设合肥蜀山网站开发
  • 建设网站的制作步骤wordpress浏览最多的文章
  • 怎么面试一个网站开发的人互联网装修公司排行榜
  • 创建网站主题在哪里网站模板工具
  • 四川网站建设套餐网站建设得花多钱
  • 网站响应式和非响应式站长工具平台
  • 网站空间管理站查企业免费
  • 海口专业做网站用php做网站的开发工具
  • 网站目录结构高端网络建站
  • 虚拟体验网站网页小游戏源码
  • 自己个人的网站怎么设计移动互联网平台有哪些