opengl 选择对象,正投影,透视投影 显示3d坐标 pyqt

opengl 选择对象,显示3d坐标 pyqt 正投影,透视投影

import copy
import sys
from PyQt5.QtWidgets import QOpenGLWidget, QApplication, QMainWindow
from PyQt5.QtCore import Qt, QPoint
from OpenGL.GL import *
from OpenGL.GLU import *
import cv2
import numpy as np

def point_to_line_distance(points, line_segments):

    x0, y0, x1, y1=line_segments[0][0], line_segments[0][1], line_segments[1][0], line_segments[1][1]
    px,py=points[0],points[1]
    """计算点到线段的距离"""
    line_mag = np.sqrt((x1 - x0) ** 2 + (y1 - y0) ** 2)
    if line_mag < 1e-6:
        return np.sqrt((px - x0) ** 2 + (py - y0) ** 2)

    u = ((px - x0) * (x1 - x0) + (py - y0) * (y1 - y0)) / (line_mag ** 2)
    if u < 0.0 or u > 1.0:
        # 最近点在线段外
        ix = min(max(x0, x1), max(min(x0, x1), px))
        iy = min(max(y0, y1), max(min(y0, y1), py))
    else:
        # 最近点在线段上
        ix = x0 + u * 

相关推荐

最近更新

  1. TCP协议是安全的吗?

    2024-06-10 09:12:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-10 09:12:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-10 09:12:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-10 09:12:02       20 阅读

热门阅读

  1. 设计模式-原型模式

    2024-06-10 09:12:02       10 阅读
  2. (20)DAC接口--->(005)FPGA实现AD5601接口(五)

    2024-06-10 09:12:02       10 阅读
  3. Set up a WordPress blog with Nginx

    2024-06-10 09:12:02       7 阅读
  4. 为什么选择Python作为AI开发语言

    2024-06-10 09:12:02       10 阅读
  5. 数字化那点事:一文读懂智慧城市

    2024-06-10 09:12:02       8 阅读
  6. unity中常见的角色控制方法

    2024-06-10 09:12:02       8 阅读
  7. 在 .NET Core 中构建工作服务和调度运行

    2024-06-10 09:12:02       9 阅读
  8. (051)FPGA时钟--->(001)时钟介绍

    2024-06-10 09:12:02       11 阅读
  9. 【运维】如何在Ubuntu 22上使用Python 3.8的虚拟环境

    2024-06-10 09:12:02       10 阅读
  10. 在 React 应用中怎么使用useImperativeHandle?

    2024-06-10 09:12:02       7 阅读
  11. 【280个shell脚本】----提示运维工作效率

    2024-06-10 09:12:02       8 阅读