当前位置:网站首页>Distance from point to line intersection and included angle of line
Distance from point to line intersection and included angle of line
2022-07-05 22:19:00 【alex1801】
1、 The distance between a point and a line
P The straight line AB Distance of .
//P For a little off the line ,AB Two endpoints for the segment
float getDist_P2L(CvPoint pointP, CvPoint pointA, CvPoint pointB)
{
// Find the linear equation
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;
// Substitute the formula of the distance from the point to the straight line
float distance = 0;
distance = ((float)abs(A*pointP.x + B*pointP.y + C)) / ((float)sqrtf(A*A + B*B));
return distance;
}
2、 The intersection of lines
Using point oblique expression to express straight line , Then solve the equations composed of two straight lines .
Solution :
x0 = (b2 - b1) / (k1 - k2 + 1e-4)
y0 = k1 * x0 + b1
3、 The included angle of the straight line
We know straight lines l1:y=k1x+b1,l2:y=k2x+b2, Find the angle between these two lines .
Conclusion :
l1 To l2 The steering angle of is θ, be tanθ=(k2- k1)/(1+ k1*k2)
l1 And l2 An Angle of θ, be tanθ=∣(k2- k1)/(1+ k1*k2)∣
Be careful : The included angle of two straight lines refers to the angle formed by two straight lines less than 90° Acute angle of , Obviously, in the included angle formula “ horn ” It's not always the angle between two straight lines .
边栏推荐
- Postman核心功能解析-参数化和测试报告
- 2022-07-05: given an array, you want to query the maximum value in any range at any time. If it is only established according to the initial array and has not been modified in the future, the RMQ meth
- How to view Apache log4j 2 remote code execution vulnerability?
- Leetcode simple question: find the nearest point with the same X or Y coordinate
- 微服務鏈路風險分析
- How to reverse a string fromCharCode? - How to reverse String. fromCharCode?
- 笔记本电脑蓝牙怎么用来连接耳机
- Pl/sql basic syntax
- Go语言学习教程(十五)
- MySQL disconnection reports an error MySQL ldb_ exceptions. OperationalError 4031, The client was disconnected by the server
猜你喜欢
A substring with a length of three and different characters in the leetcode simple question
A trip to Suzhou during the Dragon Boat Festival holiday
Bitbucket installation configuration
700. Search in a Binary Search Tree. Sol
What about data leakage? " Watson k'7 moves to eliminate security threats
MySQL actual combat 45 lecture learning (I)
Overview of concurrency control
Pl/sql basic case
Web3为互联网带来了哪些改变?
The Blue Bridge Cup web application development simulation competition is open for the first time! Contestants fast forward!
随机推荐
2022软件测试工程师涨薪攻略,3年如何达到30K
元宇宙中的三大“派系”
The statistics of leetcode simple question is the public string that has appeared once
database mirroring
MySQL连接断开报错MySQLdb._exceptions.OperationalError 4031, The client was disconnected by the server
Pl/sql basic syntax
FBO and RBO disappeared in webgpu
Two stage locking protocol for concurrency control
The difference between MVVM and MVC
Meituan dynamic thread pool practice ideas, open source
Wonderful review of the digital Expo | highlight scientific research strength, and Zhongchuang computing power won the digital influence enterprise award
Nacos 的安装与服务的注册
数博会精彩回顾 | 彰显科研实力,中创算力荣获数字化影响力企业奖
The American Championship is about to start. Are you ready?
数据泄露怎么办?'华生·K'7招消灭安全威胁
Summary of concurrency control
[groovy] mop meta object protocol and meta programming (execute groovy methods through metamethod invoke)
Leetcode simple question: the minimum cost of buying candy at a discount
Search: Future Vision (moving sword)
MySQL服务莫名宕机的解决方案