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

如何用c语言做钓鱼网站医院网站建设目的

如何用c语言做钓鱼网站,医院网站建设目的,wordpress外观插件,东营网站开发核心原理分析 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://www.dtcms.com/a/531323.html

相关文章:

  • 寿县移动公司网站建设盐城seo 优化
  • 烟台专业做网站河北专业网站建设
  • 一般做音响的有哪些网站韩国导航地图中文版app
  • 公司网站建设制作难么订制电子商务网站 价格
  • 强化 门户网站建设网站建设与运营方案
  • 百度网站建设制作公司大丰网站建设找哪家好
  • 自己做一个微信小程序需要多少钱嘉兴网站广优化公司
  • wordpress做图片站的可能性html网页制作背景图片
  • 网站怎么做app吗怎么查看网站是否被收录
  • 临沂做企业网站的公司wordpress ios使用
  • 如何降低网站跳出率wordpress 制作论坛
  • 驻马店市做网站建筑工程网目密度
  • 巴中微网站建设市场营销七大策略
  • 徐州服饰网站建设打开网站说建设中是什么问题?
  • 常州网站制作费用金华关键词优化平台
  • 怎么创建免费网站吗网站的设计方案
  • 网站开发流程需要用到的语言网站运营的概念
  • 72建站网如何建设一个药材网站网站安全防黑联盟
  • vps搭建asp网站展厅网站
  • asp.net网站开发文档廊坊企业网站团队
  • 重庆家政公司网站建设网站分析案例
  • 魔方网站导航设计付费推广网站
  • 摄影网站建设需求分析百度免费云服务器
  • 微信公众号怎么做网站的编写软件的步骤
  • 视频嵌入网站ps高手教学网站
  • 输入网站域名宁波教育学会网站建设
  • 温州企业网站开发wordpress 社区 插件
  • 网站建设成都市网站开发入门习题
  • 与建设通相关的网站百度推广官网
  • 如何做cpa单页网站赣州新闻综合频道回放