当前位置:网站首页>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
边栏推荐
- OpenCVSharpSample05Wpf
- [dest0g3 520 orientation] dest0g3, which has been a long time since we got WP_ heap
- Huawei equipment configures private IP routing FRR
- Record: how to solve the problem of "the system cannot find the specified path" in the picture message uploaded by transferto() of multipartfile class [valid through personal test]
- [work with notes] MFC solves the problem that pressing ESC and enter will automatically exit
- JS get element
- After idea uses c3p0 connection pool to connect to SQL database, database content cannot be displayed
- How to do Internet for small enterprises
- How can intelligent safe power distribution devices reduce the occurrence of electrical fire accidents?
- Jump model between mirrors
猜你喜欢
Review the history of various versions of ITIL, and find the key points for the development of enterprise operation and maintenance
智能安全配电装置如何减少电气火灾事故的发生?
Solution of depth learning for 3D anisotropic images
0- blog notes guide directory (all)
(novice to) detailed tutorial on machine / in-depth learning with colab from scratch
ROS learning-8 pit for custom action programming
Fast Color Segementation
04路由跳转并携带参数
ROS learning -5 how function packs with the same name work (workspace coverage)
Thesis reading - autovc: zero shot voice style transfer with only autoencoder loss
随机推荐
1、 Set up Django automation platform (realize one click SQL execution)
[keras learning]fit_ Generator analysis and complete examples
Understanding and thinking about multi-core consistency
cmake_ example
[51nod.3210] binary Statistics (bit operation)
How to do Internet for small enterprises
ROS learning -5 how function packs with the same name work (workspace coverage)
Common web page status return code crawler
Open source video recolor code
Armv8-m (Cortex-M) TrustZone summary and introduction
Uniapp preview function
[reading papers] comparison of deeplobv1-v3 series, brief review
[reading papers] deep learning face representation from predicting 10000 classes. deepID
Paper reading - group normalization
[pytorch] kaggle large image dataset data analysis + visualization
Mbedtls migration experience
JS get element
Number of special palindromes in basic exercise of test questions
An image is word 16x16 words: transformers for image recognition at scale
CCF 201409-1: adjacent number pairs (100 points + problem solving ideas)