How to Get Vertical Line from Point and Line
Description
How to get vertical line cross one point which out of line in line.
QPoint Line::VerticalPoint(QPoint pt)
{
QPointF ptCross = pt;
double dtY = static_cast<double>(y1() - y2());
double dtX = static_cast<double>(x1() - x2());
double k,b,m;
/** 0 = kx +b -y; 对应垂线方程为 -x -ky + m = 0;(mm为系数) */
if(abs(dtX - 0) < 1e-10){
ptCross = QPointF(x1(),pt.y());
goto _END;
}
if(abs(dtY - 0) < 1e-10){
ptCross = QPointF(pt.x(),y1());
goto _END;
}
k = dtY/dtX;
b = (y1()-k*x1());
m = pt.x() + k*pt.y();
ptCross.setX((m-k*b)/(k*k + 1));
ptCross.setY(k*ptCross.x()+b);
_END:
return ptCross.toPoint();
}
How to Get Vertical Line from Point and Line的更多相关文章
- Go to the first line OR the last line of the file
(1) 跳到首行 :1 或 gg (2)跳到最后一行 :$ 或 G 或shift+g(大写.当前若大小写锁定直接按g,未锁定则按shift+g)
- [笔记]The Linux command line
Notes on The Linux Command Line (by W. E. Shotts Jr.) edited by Gopher 感觉博客园是不是搞了什么CSS在里头--在博客园显示效果挺 ...
- [LeetCode] Max Points on a Line 题解
题意 Given n points on a 2D plane, find the maximum number of points that lie on the same straight lin ...
- Detect Vertical&Horizontal Segments By OpenCV
Detect Vertical&Horizontal Segments By OpenCV,and Save the data to csv. Steps: Using adaptiveThr ...
- PAT A 1014. Waiting in Line (30)【队列模拟】
题目:https://www.patest.cn/contests/pat-a-practise/1014 思路: 直接模拟类的题. 线内的各个窗口各为一个队,线外的为一个,按时间模拟出队.入队. 注 ...
- [CareerCup] 7.6 The Line Passes the Most Number of Points 经过最多点的直线
7.6 Given a two-dimensional graph with points on it, find a line which passes the most number of poi ...
- 简单几何(直线求交点) POJ 2074 Line of Sight
题目传送门 题意:从一条马路(线段)看对面的房子(线段),问连续的能看到房子全部的最长区间 分析:自己的思路WA了:先对障碍物根据坐标排序,然后在相邻的障碍物的间隔找到区间,这样还要判断是否被其他障碍 ...
- Jmeter html 报告中添加90% line time
转载南风_real博客园:http://www.cnblogs.com/jaychang/p/5784882.html 首先上效果图: 其次明白几个原理: 90% Line的意思是:一组数由小到大进行 ...
- 【BZOJ】【3301】【USACO2011 Feb】Cow Line
康托展开 裸的康托展开&逆康托展开 康托展开就是一种特殊的hash,且是可逆的…… 康托展开计算的是有多少种排列的字典序比这个小,所以编号应该+1:逆运算同理(-1). 序列->序号:( ...
随机推荐
- Python 傅里叶分析
0. 一维序列卷积 np.convolve,注意 same/valid参数下(默认为 full),序列卷积出的结果的长度: >> np.convolve([1, 2, 3], [0, 1, ...
- 用 dotTrace 进行性能分析时,各种不同性能分析选项的含义和用途
对 .NET 程序进行性能分析,dotTrace 能应对绝大多数的场景.在开启一个进程进行性能分析之前,我们会看到一些性能分析选项(Profiler Options).本文将介绍这几个选项的含义,并用 ...
- PHP如何清除COOKIE?PHP无法删除COOKIE?设置COOKIE有效期、COOKIE过期
cookie和session的区别? http://www.cnblogs.com/phphuaibei/archive/2011/11/15/2250082.html PHP如何清除COOKIE?P ...
- 修改panabit web管理介面端口
panabit使用mini_httpd为web发布平台,版本为1.19.使用https协议发布,端口443,运行命令为/usr/panabit/bin/ipe_httpd. panabit启动时使用/ ...
- 一个单元测试 学习 aysnc await
using System; using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; name ...
- Bootstrap-Other:UI 编辑器
ylbtech-Bootstrap-Other:UI 编辑器 1.返回顶部 1. Bootstrap UI 编辑器 以下是 15 款最好的 Bootstrap 编辑器或者是在线编辑工具. 1. Boo ...
- 文件读取错误UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 884: invalid start byte
参考: https://segmentfault.com/q/1010000004268196/a-1020000004269556 ubuntu下Python3使用open('filename', ...
- [转]Web 调试工具之 Advanced REST client
原文:http://bbs.itcast.cn/forum.php?mod=viewthread&tid=85654 安装方式: 3.1. 如果你能FQ访问谷歌商店,那么就简单了 在这里直接安 ...
- Java ScriptEngine 解析js
Java ScriptEngine 解析js 1.脚本引擎 ① 通过脚本名称获取: ScriptEngine engine = new ScriptEngineManager().getEn ...
- mysql-1安装和数据库的管理
1.安装 直接docker安装,客户端使用Navicat Premium. docker run -d --name csjmysql -p 3306:3306 -e MYSQL_ROOT_PASSW ...