当前位置:网站首页>Common scenes of vector product in image
Common scenes of vector product in image
2022-04-23 21:57:00 【Three stone orders】
Cross product ( Vector product ) Definition :
1、a×b or a∧b, The result is scalar ;
2、 Vector product |c|=|a×b|=|a||b|sin<a,b>, namely c The length of is numerically equal to a,b, The included angle is θ The area of the parallelogram formed ;
3、a=(x1,y1),b=(x2,y2), be a×b=x1y2-y1x2;
4、a×b Less than 0, vector a Less than 180° Rotate counterclockwise to vector b;a×b Greater than 0, vector a Less than 180° Rotate clockwise to vector b;a×b be equal to 0, vector a Parallel and vector b;
Reference scene 1:
OpenCV in contourArea Contour area algorithm , Suppose that the contour point (A、B、C) Sort clockwise ,O Origin ,OA×OB Is the area of the corresponding parallelogram , Half is a triangle OAB The area of ( Green area )
Then there are ABC The area of =OA×OB×0.5+OB×OC×0.5+OC×OA×0.5, among OC×OA In the opposite direction ;
Reference scene 2:
When a set of points with any distribution is sorted clockwise by bubbling method , You need to determine the direction of the two vectors , Such as OA Rotate to OB Clockwise or counterclockwise .
bool IsAnticlockwise(Point O, Point a, Point b)
{
// If oa Rotate clockwise to ob The angle of is less than 180°, return false, Otherwise return to true
if (a.x >= 0 && b.x < 0)
return true;
if (a.x == 0 && b.x == 0)
return a.y > b.y;
// vector OA Sum vector OB Cross product of
int det = (a.x - O.x) * (b.y - O.y) - (b.x - O.x) * (a.y - O.y);
if (det < 0)
return true;
if (det > 0)
return false;
// vector OA Sum vector OB Collinear , Judge the size by distance
int d1 = (a.x - O.x) * (a.x - O.x) + (a.y - O.y) * (a.y - O.y);
int d2 = (b.x - O.x) * (b.x - O.y) + (b.y - O.y) * (b.y - O.y);
return d1 > d2;
}
Reference scene 3:
Judge whether the line segments intersect by the positive and negative cross product of two vectors ;
https://blog.csdn.net/li1615882553/article/details/80372202
other :
Pay attention to distinguish dot product ( To multiply ), The result is a vector ,v1.v2=|v1|*|v2|*cosθ
版权声明
本文为[Three stone orders]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204200615437236.html
边栏推荐
- Problem brushing plan -- dynamic programming (III)
- Xiaomi mobile phone has abandoned the "Mi" brand all over the world and switched to the full name brand of "Xiaomi"
- 阿里云回应用户注册信息泄露事件
- Display, move, rotate
- Swift import third-party library reports an error no such module““
- [leetcode sword finger offer 10 - II. Frog jumping steps (simple)]
- setInterval、setTimeout、requestAnimationFrame
- 管道和xargs
- Flomo software recommendation
- Code cloud download history version process
猜你喜欢
2.整理华子面经--2
[leetcode refers to the two numbers of offer 57. And S (simple)]
Database experiment VI integrity language experiment
亚马逊和Epic将入驻,微软应用商城向第三方开放
Pycharm download and installation
DW basic course (II)
[leetcode refers to offer 18. Delete the node of the linked list (simple)]
Flomo software recommendation
小米手机全球已舍弃“MI”品牌,全面改用“xiaomi”全称品牌
This paper solves the cross domain problem of browser
随机推荐
Yolov5 NMS source code understanding
2.整理华子面经--2
FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ‘:app:stripDe
ROS learning notes - tutorial on the use of ROS
引入结构化并发,Swift 5.5 发布!
[leetcode refers to offer 32 - III. print binary tree III from top to bottom (medium)]
Online Excel to CSV tool
Code cloud download history version process
Deno 1.13.2 发布
Database Experiment four View experiment
JS to get the browser and screen height
Centos7 builds MySQL master-slave replication from scratch (avoid stepping on the pit)
阿里又一个“逆天”容器框架!这本Kubernetes进阶手册简直太全了
Problem brushing plan -- dynamic programming (III)
[leetcode refers to the substructure of offer 26. Tree (medium)]
Preliminary analysis of Airbase
亚马逊和Epic将入驻,微软应用商城向第三方开放
Realrange, reduce, repeat and einops in einops package layers. Rearrange and reduce in torch. Processing methods of high-dimensional data
Error message: b04access.00f eve'. Read of address 000001B4
Cancel the default open project setting of idea