当前位置:网站首页>點到直線的距離直線的交點及夾角
點到直線的距離直線的交點及夾角
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°的銳角,顯然夾角公式中的“角”並不都是兩直線的夾角。
边栏推荐
- 509. Fibonacci Number. Sol
- PyGame practical project: write Snake games with 300 lines of code
- Nacos installation and service registration
- Three "factions" in the metauniverse
- 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
- Recovery technology with checkpoints
- 从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
- Leetcode simple question: the minimum cost of buying candy at a discount
- The American Championship is about to start. Are you ready?
- What if win11 is missing a DLL file? Win11 system cannot find DLL file repair method
猜你喜欢
2022软件测试工程师涨薪攻略,3年如何达到30K
Pl/sql basic syntax
A substring with a length of three and different characters in the leetcode simple question
Livelocks and deadlocks of concurrency control
Granularity of blocking of concurrency control
What if the files on the USB flash disk cannot be deleted? Win11 unable to delete U disk file solution tutorial
【愚公系列】2022年7月 Go教学课程 003-IDE的安装和基本使用
The American Championship is about to start. Are you ready?
Server optimization of performance tuning methodology
Business learning of mall commodity module
随机推荐
A substring with a length of three and different characters in the leetcode simple question
Oracle is sorted by creation time. If the creation time is empty, the record is placed last
ESP32 hosted
[Chongqing Guangdong education] National Open University autumn 2018 0088-21t Insurance Introduction reference questions
[groovy] mop meta object protocol and meta programming (execute groovy methods through metamethod invoke)
Recovery technology with checkpoints
Business learning of mall order module
119. Pascal‘s Triangle II. Sol
Oracle triggers
GWT module may need to be (RE) compiled reduce - GWT module may need to be (RE) compiled reduce
When the industrial Internet era is truly mature, we will look at the emergence of a series of new industrial giants
MySQL连接断开报错MySQLdb._exceptions.OperationalError 4031, The client was disconnected by the server
航海日答题小程序之航海知识竞赛初赛
Sentinel production environment practice (I)
FBO and RBO disappeared in webgpu
70. Climbing Stairs. Sol
Two stage locking protocol for concurrency control
从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
Shelved in TortoiseSVN- Shelve in TortoiseSVN?
The new content of the text component can be added through the tag_ Config set foreground and background colors