当前位置:网站首页>點到直線的距離直線的交點及夾角
點到直線的距離直線的交點及夾角
2022-07-05 22:18:00 【alex1801】
1、點到直線的距離
P到直線AB的距離。
//P為線外一點,AB為線段兩個端點
float getDist_P2L(CvPoint pointP, CvPoint pointA, CvPoint pointB)
{
//求直線方程
int A = 0, B = 0, C = 0;
A = pointA.y - pointB.y;
B = pointB.x - pointA.x;
C = pointA.x*pointB.y - pointA.y*pointB.x;
//代入點到直線距離公式
float distance = 0;
distance = ((float)abs(A*pointP.x + B*pointP.y + C)) / ((float)sqrtf(A*A + B*B));
return distance;
}
2、直線的交點
利用點斜式錶達直線,然後求解兩條直線組成的方程組。
解得:
x0 = (b2 - b1) / (k1 - k2 + 1e-4)
y0 = k1 * x0 + b1
3、直線的夾角
已知直線 l1:y=k1x+b1,l2:y=k2x+b2,求這兩條直線的夾角。
結論:
l1 到 l2 的轉向角為 θ,則 tanθ=(k2- k1)/(1+ k1*k2)
l1 與 l2 的夾角為 θ,則 tanθ=∣(k2- k1)/(1+ k1*k2)∣
注意:兩直線的夾角指的是兩直線所成的小於90°的銳角,顯然夾角公式中的“角”並不都是兩直線的夾角。
边栏推荐
- Leetcode simple question: check whether each row and column contain all integers
- Character conversion PTA
- Assign the output of a command to a variable [repeat] - assigning the output of a command to a variable [duplicate]
- Text组件新增内容通过tag_config设置前景色、背景色
- 2022软件测试工程师涨薪攻略,3年如何达到30K
- ESP32 hosted
- How to develop and introduce applet plug-ins
- Reptile practice
- The difference between MVVM and MVC
- What changes has Web3 brought to the Internet?
猜你喜欢
2022-07-05:给定一个数组,想随时查询任何范围上的最大值。 如果只是根据初始数组建立、并且以后没有修改, 那么RMQ方法比线段树方法好实现,时间复杂度O(N*logN),额外空间复杂度O(N*
boundary IoU 的计算方式
Metaverse Ape上线倒计时,推荐活动火爆进行
Decorator learning 01
【愚公系列】2022年7月 Go教学课程 003-IDE的安装和基本使用
科技云报道:算力网络,还需跨越几道坎?
Technology cloud report won the special contribution award for the 10th anniversary of 2013-2022 of the "cloud Ding Award" of the global cloud computing conference
科技云报道荣膺全球云计算大会“云鼎奖”2013-2022十周年特别贡献奖
Talking about MySQL index
Oracle triggers
随机推荐
Three "factions" in the metauniverse
Installation of VMware Workstation
Livelocks and deadlocks of concurrency control
The statistics of leetcode simple question is the public string that has appeared once
Talking about MySQL index
Solutions for unexplained downtime of MySQL services
Comment développer un plug - in d'applet
MySQL连接断开报错MySQLdb._exceptions.OperationalError 4031, The client was disconnected by the server
Sparse array [matrix]
Common interview questions of redis factory
When the industrial Internet era is truly mature, we will look at the emergence of a series of new industrial giants
The American Championship is about to start. Are you ready?
A number of ventilator giants' products have been recalled recently, and the ventilator market is still in incremental competition
Leetcode simple question check whether all characters appear the same number of times
AD637使用笔记
元宇宙中的三大“派系”
Unique occurrence times of leetcode simple questions
Postman核心功能解析-参数化和测试报告
Damn, window in ie open()
Interprocess communication in the "Chris Richardson microservice series" microservice architecture