当前位置:网站首页>点到直线的距离直线的交点及夹角
点到直线的距离直线的交点及夹角
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°的锐角,显然夹角公式中的“角”并不都是两直线的夹角。
边栏推荐
- 2022-07-05:给定一个数组,想随时查询任何范围上的最大值。 如果只是根据初始数组建立、并且以后没有修改, 那么RMQ方法比线段树方法好实现,时间复杂度O(N*logN),额外空间复杂度O(N*
- MySQL actual combat 45 lecture learning (I)
- Oracle views the data size of a table
- The real situation of programmers
- What about data leakage? " Watson k'7 moves to eliminate security threats
- Livelocks and deadlocks of concurrency control
- Implementation technology of recovery
- A substring with a length of three and different characters in the leetcode simple question
- Basic grammar of interview (Part 1)
- U盘的文件无法删除文件怎么办?Win11无法删除U盘文件解决教程
猜你喜欢
多家呼吸机巨头产品近期被一级召回 呼吸机市场仍在增量竞争
Calculation method of boundary IOU
Index optimization of performance tuning methodology
AD637使用笔记
Leetcode simple question ring and rod
IIC bus realizes client device
Leetcode simple question check whether all characters appear the same number of times
元宇宙中的三大“派系”
Ad637 notes d'utilisation
90后测试员:“入职阿里,这一次,我决定不在跳槽了”
随机推荐
Web3为互联网带来了哪些改变?
Alternating merging strings of leetcode simple questions
[Yugong series] go teaching course in July 2022 004 go code Notes
Performance testing of software testing
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
boundary IoU 的计算方式
Depth first DFS and breadth first BFS -- traversing adjacency tables
微服务入门(RestTemplate、Eureka、Nacos、Feign、Gateway)
Win11 runs CMD to prompt the solution of "the requested operation needs to be promoted"
Unique occurrence times of leetcode simple questions
Regular expressions and re Libraries
Blocking of concurrency control
Daily question brushing record (XIV)
The new content of the text component can be added through the tag_ Config set foreground and background colors
Meituan dynamic thread pool practice ideas, open source
Character conversion PTA
Pl/sql basic case
【愚公系列】2022年7月 Go教学课程 003-IDE的安装和基本使用
Oracle triggers
Stored procedures and stored functions