当前位置:网站首页>点到直线的距离直线的交点及夹角
点到直线的距离直线的交点及夹角
2022-07-05 22:17: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°的锐角,显然夹角公式中的“角”并不都是两直线的夹角。
边栏推荐
- 数博会精彩回顾 | 彰显科研实力,中创算力荣获数字化影响力企业奖
- Serializability of concurrent scheduling
- Reptile practice
- Understand the basic concept of datastore in Android kotlin and why SharedPreferences should be stopped in Android
- AD637使用笔记
- Metaverse Ape猿界应邀出席2022·粤港澳大湾区元宇宙和web3.0主题峰会,分享猿界在Web3时代从技术到应用的文明进化历程
- Analysis of the problem that the cookie value in PHP contains a plus sign (+) and becomes a space
- Oracle triggers
- "Chris Richardson microservices series" uses API gateway to build microservices
- 如何快速体验OneOS
猜你喜欢
2022软件测试工程师涨薪攻略,3年如何达到30K
K210 learning notes (IV) k210 runs multiple models at the same time
Overview of concurrency control
boundary IoU 的计算方式
Implementation technology of recovery
[Yugong series] go teaching course 003-ide installation and basic use in July 2022
Three "factions" in the metauniverse
Serializability of concurrent scheduling
Damn, window in ie open()
Advantages and disadvantages of the "Chris Richardson microservice series" microservice architecture
随机推荐
A number of ventilator giants' products have been recalled recently, and the ventilator market is still in incremental competition
boundary IoU 的计算方式
Interview questions for famous enterprises: Coins represent a given value
What changes has Web3 brought to the Internet?
Metaverse Ape上线倒计时,推荐活动火爆进行
实战:fabric 用户证书吊销操作流程
What if win11 is missing a DLL file? Win11 system cannot find DLL file repair method
Ad637 notes d'utilisation
微服務鏈路風險分析
90后测试员:“入职阿里,这一次,我决定不在跳槽了”
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
Index optimization of performance tuning methodology
Sparse array [matrix]
How to develop and introduce applet plug-ins
Shell script, awk uses if, for process control
Business learning of mall order module
The Blue Bridge Cup web application development simulation competition is open for the first time! Contestants fast forward!
Win11 runs CMD to prompt the solution of "the requested operation needs to be promoted"
多家呼吸机巨头产品近期被一级召回 呼吸机市场仍在增量竞争
Understand the basic concept of datastore in Android kotlin and why SharedPreferences should be stopped in Android