当前位置:网站首页>點到直線的距離直線的交點及夾角
點到直線的距離直線的交點及夾角
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°的銳角,顯然夾角公式中的“角”並不都是兩直線的夾角。
边栏推荐
- The new content of the text component can be added through the tag_ Config set foreground and background colors
- Win11缺少dll文件怎么办?Win11系统找不到dll文件修复方法
- Two stage locking protocol for concurrency control
- 数据泄露怎么办?'华生·K'7招消灭安全威胁
- 如何创建线程
- 如何向mongoDB中添加新的字段附代码(全)
- Cobaltstrike builds an intranet tunnel
- 1.3 years of work experience, double non naked resignation agency face-to-face experience [already employed]
- Overriding equals() & hashCode() in sub classes … considering super fields
- Common interview questions of JVM manufacturers
猜你喜欢
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
The difference between MVVM and MVC
Web3为互联网带来了哪些改变?
Overview of database recovery
PyGame practical project: write Snake games with 300 lines of code
实战:fabric 用户证书吊销操作流程
Nacos 的安装与服务的注册
Database recovery strategy
Metaverse Ape上线倒计时,推荐活动火爆进行
Talking about MySQL index
随机推荐
Sub total of Pico development
Implementation technology of recovery
Leetcode simple question check whether all characters appear the same number of times
Analyse des risques liés aux liaisons de microservices
Getting started with microservices (resttemplate, Eureka, Nacos, feign, gateway)
Postman核心功能解析-参数化和测试报告
极狐公司官方澄清声明
[Yugong series] go teaching course in July 2022 004 go code Notes
Database tuning solution
Index optimization of performance tuning methodology
点到直线的距离直线的交点及夹角
Sentinel production environment practice (I)
如何快速体验OneOS
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
Blocking protocol for concurrency control
database mirroring
The new content of the text component can be added through the tag_ Config set foreground and background colors
How to reverse a string fromCharCode? - How to reverse String. fromCharCode?
ESP32 hosted
Promql demo service