当前位置:网站首页>Matlab: find the inner angle of n-sided concave polygon
Matlab: find the inner angle of n-sided concave polygon
2022-06-13 02:30:00 【weixin_ forty-five million six hundred and thirty-three thousan】
Find the inner angle of a concave polygon
Most of our common polygons are convex , That is, each inner corner θ Less than 180° The polygon of . And some inner corners of a concave polygon θ Greater than 180°. stay Matlab When finding the inner angle of a polygon , The known condition is usually the coordinates of all vertices of a polygon . If it is a general convex polygon , We can use the coordinates of three adjacent points , Think of it as the three vertices of a triangle , Find the included angle on both sides , That is, the interior angle of the polygon vertex . The formula is as follows :
Or think of these three points as two vectors , Calculate the angle between vectors by dot product and norm . The formula is as follows :
When using manual calculation , For the interior angle of a concave polygon , Just find the corresponding inner corner , Use 360°-θ that will do . However ,Matlab When calculating with the above formula , It is not possible to identify which inner corner is concave or convex , The results are all convex interior angles , Less than 180°. therefore , It is necessary to judge the concave convex property of the internal angle through other function functions , To correctly calculate the inner angle of a concave polygon .
Matlab There are already big men in the community Are Mjaavatten Write a function to judge the concave convex property of the inner corner :convex, Can be in matlab Log in to the official website and download it directly to call .
stay Matlab Community File Exchange Many excellent function functions contributed by big guys can be found in , It is recommended to find some convenient extension functions .
% ps Containing the coordinates of a polygon nx2 matrix
c = convex(ps); % convex The function determines whether the interior angle of the corresponding vertex is greater than 180°
for k = 1 : size(ps, 1)-2
point1 = ps(k, :);
vertex = ps(k+1, :);
point2 = ps(k+2, :);
v1 = point1 - vertex;
v2 = point2 - vertex;
% Use dot product and norm to find angle , Need to use c Value to determine whether the internal angle is greater than 180°
theta(k) = dot(v1, v2)/(norm(v1)*norm(v2)); % dot Point product function ,norm Norm modular function
if c(k)>0
angle(k) = (acos(theta(k)))*180/pi;
else
angle(k) = 360 - (acos(theta(k)))*180/pi;
end
end
Complete code
边栏推荐
- ROS learning-8 pit for custom action programming
- Image table solid line and dashed line detection
- [reading papers] transformer miscellaneous notes, especially miscellaneous
- [work with notes] MFC solves the problem that pressing ESC and enter will automatically exit
- 03 recognize the first view component
- Paper reading - beat tracking by dynamic programming
- too old resource version,Code:410
- [pytorch] kaggle image classification competition arcface + bounding box code learning
- 02 优化微信开发者工具默认的结构
- Leetcode 450. Delete node in binary search tree [binary search tree]
猜你喜欢
![[learning notes] xr872 GUI littlevgl 8.0 migration (file system)](/img/9b/0bf88354e8cfdbcc1ea91311c9a823.jpg)
[learning notes] xr872 GUI littlevgl 8.0 migration (file system)

Is space time attention all you need for video understanding?

Deep learning the principle of armv8/armv9 cache

Yovo3 and yovo3 tiny structure diagram

Chapter7-13_ Dialogue State Tracking (as Question Answering)

04路由跳转并携带参数

Mbedtls migration experience

Mean Value Coordinates

Configuring virtual private network FRR for Huawei equipment
![[pytorch]fixmatch code explanation - data loading](/img/0f/1165dbe4c7410a72d74123ec52dc28.jpg)
[pytorch]fixmatch code explanation - data loading
随机推荐
1、 Set up Django automation platform (realize one click SQL execution)
Superficial understanding of conditional random fields
03 recognize the first view component
Configuring virtual private network FRR for Huawei equipment
Understanding and thinking about multi-core consistency
too old resource version,Code:410
Area of basic exercise circle ※
How to learn to understand Matplotlib instead of simple code reuse
Microsoft Pinyin opens U / V input mode
Example 4 linear filtering and built-in filtering
[reading some papers] introducing deep learning into the public horizon alexnet
Redis multiple servers share one
Chapter7-10_ Deep Learning for Question Answering (1/2)
Several articles on norms
[reading point paper] deeplobv3+ encoder decoder with Atlas separable revolution
Redirection setting parameters -redirectattributes
A real-time target detection model Yolo
Chapter7-12_ Controllable Chatbot
The precision of C language printf output floating point numbers
Fast Color Segementation