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

正交视图三维重建 笔记 2d线到3d线

这种代码怎么写好,x1==tx1 x2==tx2 x1x2在一条线上tx2和tx1在一条线上输出x1 y1 ty1,x2 y2 ty2

 

线过的点 的集合

俯视图找深度

测试一下 

目标

四条线变一条线

复杂度贼大跑起来贼慢

加了16000条

去重

for (const [x1, y1, x2, y2, lineId, type] of frontpointlist) {for (const [x3, y3, x4, y4, lineId2, type2] of toppointlist) {if (x1 === x3 && x2 === x4) {const drawline1=[x1, y1, y3 - clusterMinY, x2, y2, y3 - clusterMinY]const drawline2=[x1, y1, y4 - clusterMinY, x2, y2, y4 - clusterMinY]const key = drawline1.map(v => v.toFixed(2)).join(',');if (!seenLinePairs.has(key)) {seenLinePairs.add(key);lines3d.push([x1, y1, y3 - clusterMinY, x2, y2, y3 - clusterMinY, lineId, type]);}const key2 = drawline2.map(v => v.toFixed(2)).join(',');if (!seenLinePairs.has(key2)) {seenLinePairs.add(key2);lines3d.push([x1, y1, y4 - clusterMinY, x2, y2, y4 - clusterMinY, lineId, type]);}}}
}

上下分离

俯视图的拉伸需要旋转

yz调换

升天

俯视图z忘记归零了

多了4条线,不过问题不大,不影响生成面,生成面是要闭合环

经典缺线

分开判断看看

多这条线是不能容忍的

飞了

取x,x不一样

这条线不存在于俯视图

按x方向投

主视图侧视图投影线需要在俯视图里

for (const [x1, y1, x2, y2,lineId] of mostFrequentCluster.lines) {for (const [x3, y3, x4, y4,lineId2,type] of mostFrequentCluster.lines) {
if(x1<=x3 && x2>=x4 && y1<=y3 && y2>=y4 )
{frontpointlist.push([x3, y3, x4, y4,lineId2,type]);
frontpointmap .set([x3, y3,x4, y4], true);}}
}

200,0 

捕捉不到兀线

for (const [x1, y1, x2, y2, lineId, type] of toppointlist) {for (const [x3, y3, x4, y4, lineId2, type2] of frontpointlist){if (x1 === x3 && x2 === x4) {const drawline1=[x1, y3, y1 , x2, y3, y2];const drawline2=[x1, y4, y1 , x2, y4, y2];const key = drawline1.map(v => v.toFixed(2)).join(',');if (!seenLinePairs.has(key)) {seenLinePairs.add(key);//  lines3d.push([x1, y3, y1, x2, y3, y2, lineId, type]);}const key2 = drawline2.map(v => v.toFixed(2)).join(',');if (!seenLinePairs.has(key2)) {seenLinePairs.add(key2);//  lines3d.push([x1, y4, y1 , x2, y4, y2, lineId, type]);}}}}for (const [x1, y1, x2, y2, lineId, type] of rightpointlist) {for (const [x3, y3, x4, y4, lineId2, type2] of frontpointlist) {if (y1 === y3&& y2 === y4) {const drawline1=[x3, y1, x1, x3, y2, x2];const drawline2=[x4, y1, x1, x4, y2, x2];const key = drawline1.map(v => v.toFixed(2)).join(',');if (!seenLinePairs.has(key)) {seenLinePairs.add(key);lines3d.push([x3, y1, x1, x3, y2, x2 ,lineId, type]);}const key2 = drawline2.map(v => v.toFixed(2)).join(',');if (!seenLinePairs.has(key2)) {seenLinePairs.add(key2);lines3d.push([x4, y1, x1, x4, y2, x2, lineId, type]);}}}

没什么软用

for (const [x1, y1, x2, y2,lineId] of mostFrequentCluster.lines) {for (const [x3, y3, x4, y4,lineId2,type] of mostFrequentCluster.lines) {
if(x1<=x3 && x2>=x4 && y1<=y3 && y2>=y4 )
{frontpointlist.push([x3, y3, x4, y4,lineId2,type]);
frontpointmap .set(`${x3},${y3 }`, true);
frontpointmap .set(   `${x4},${y4}`, true);}}
}
for (const [x1, y1, x2, y2,lineId] of topcluauster.lines) {for (const [x3, y3, x4, y4,lineId2,type] of topcluauster.lines) {if(x1<=x3 && x2>=x4 && y1<=y3 && y2>=y4 )
{toppointlist.push([x3, y3- clusterMinY, x4, y4- clusterMinY,lineId2,type]);
toppointmap .set(`${x3},${y3- clusterMinY }`, true);
toppointmap .set(   `${x4},${y4- clusterMinY}`, true);
}}
}
for (const [x1, y1, x2, y2,lineId] of rightcluster.lines) {for (const [x3, y3, x4, y4,lineId2,type] of rightcluster.lines) {if(x1<=x3 && x2>=x4 && y1<=y3 && y2>=y4 )
{rightpointlist.push([x3-clusterMinx, y3, x4-clusterMinx, y4,lineId2,type]);rightpointmap .set(`${x3-clusterMinx },${y3 }`, true);rightpointmap .set(   `${x4-clusterMinx },${y4}`, true);}}
}


看看别人怎么写的

 

for (const [fx1, fy1, fx2, fy2, lineId, type] of frontpointlist) {for (const [tx1, ty1, tx2, ty2, lineId2, type2] of toppointlist) {if (fx1 === tx1 && fx2 === tx2) {const A=[fx1, fy1, ty1];const Ahat=[fx1, fy1, ty2];const B=[fx2, fy2, ty1];const Bhat=[fx2, fy2, ty2];}}
}

好短

const seenLinePairs = new Set<string>(); // 用于记录已经添加过的 [lineId, lineId2] 对
function drawlines(x1:number, y1:number, z1:number , x2:number, y2:number, z2:number , lineId:number, type:number){if([x1, y1, z1].join(',') === [x2, y2, z2].join(','))return;const drawline2=[x1, y1, z1 , x2, y2,z2]const key2 = drawline2.map(v => v.toFixed(2)).join(',');if (!seenLinePairs.has(key2)) {seenLinePairs.add(key2);lines3d.push([x1, y1, z1, x2, y2, z2 , lineId, type]);}}
for (const [fx1, fy1, fx2, fy2, lineId, type] of frontpointlist) {for (const [tx1, ty1, tx2, ty2, lineId2, type2] of toppointlist) {if (fx1 === tx1 && fx2 === tx2) {const A=[fx1, fy1, ty1];const Ahat=[fx1, fy1, ty2];const B=[fx2, fy2, ty1];const Bhat=[fx2, fy2, ty2];drawlines(A[0], A[1], A[2], Ahat[0], Ahat[1], Ahat[2], lineId, type);drawlines(B[0], B[1], B[2], Bhat[0], Bhat[1], Bhat[2], lineId, type);drawlines(A[0], A[1], A[2], B[0], B[1], B[2], lineId, type);drawlines(Ahat[0], Ahat[1], Ahat[2], Bhat[0], Bhat[1], Bhat[2], lineId, type);}}
}

又缺线 

for (const [fx1, fy1, fx2, fy2, lineId, type] of frontpointlist) {for (const [tx1, ty1, tx2, ty2, lineId2, type2] of toppointlist) {if (isLineInSet([fx1,ty1,fx2,ty1] ,toplineSet)&& isLineInSet([fx1,ty2,fx2,ty2] ,toplineSet)) {const A=[fx1, fy1, ty1];const Ahat=[fx1, fy1, ty2];const B=[fx2, fy2, ty1];const Bhat=[fx2, fy2, ty2];drawlines(A[0], A[1], A[2], Ahat[0], Ahat[1], Ahat[2], lineId, type);drawlines(B[0], B[1], B[2], Bhat[0], Bhat[1], Bhat[2], lineId, type);drawlines(A[0], A[1], A[2], B[0], B[1], B[2], lineId, type);drawlines(Ahat[0], Ahat[1], Ahat[2], Bhat[0], Bhat[1], Bhat[2], lineId, type);}}
}

 

明天用rbush解决兀的情况,然后前视图俯视图调换一下看看效果

 

http://www.xdnf.cn/news/14701.html

相关文章:

  • 使用deepseek制作“喝什么奶茶”随机抽签小网页
  • Jina-Embeddings-V4:多模态向量模型的革命性突破与实战指南
  • Python生成器表达式最佳实践指南:何时使用与高效选择
  • Flutter基础(控制器)
  • Python基础(吃洋葱小游戏)
  • LINUX628 NFS 多web;主从dns;ntp;samba
  • WOE值:风险建模中的“证据权重”量化术——从似然比理论到FICO评分卡实践
  • SpringMVC系列(五)(响应实验以及Restful架构风格(上))
  • H6-108QB2W QILSTE/旗光
  • WebRTC(十二):DTLS
  • Cesium快速入门到精通系列教程十一:Cesium1.74中高性能渲染上万Polyline
  • 2025第十五届上海生物发酵展:江苏健达干燥盛装赴会
  • 数据结构:最小生成树—Prim(普里姆)与Kruskal(克鲁斯卡尔)算法
  • 使用asyncio构建高性能网络爬虫
  • Linux离线搭建Redis (centos7)详细操作步骤
  • Python助力自动驾驶:深度学习模型优化全攻略
  • Flutter基础(Riverpod)
  • 用AI给AR加“智慧”:揭秘增强现实智能互动的优化秘密
  • 【学习笔记】深入理解Java虚拟机学习笔记——第12章 Java内存模型与线程
  • RNN(循环神经网络)与LSTM(长短期记忆网络)输出的详细对比分析
  • 战神授权后台报错:Parse error: syntax error, unexpected end of file in解决办法
  • zookeeper Curator(3):Watch事件监听
  • 搭建Flink分布式集群
  • 深入详解:随机森林算法——概念、原理、实现与应用场景
  • Spring Cloud:高级特性与最佳实践
  • Python基础知识之文件
  • 深入剖析 CVE-2021-3560 与 CVE-2021-4034:原理、区别与联系
  • SQL学习笔记4
  • python基于Django+mysql实现的图书管理系统【完整源码+数据库】
  • 基于springboot的火锅店点餐系统