In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to understand the implementation of C++ program, the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
C++ program to solve the problem, the program uses the ray method, from the test point (v) level leads to a ray B (vforce w), calculate the number of B and vl boundary line intersection, to determine whether the point falls in the outer rectangle.
A C++ language program that uses ray method to determine whether a point is within a polygon. Many years ago, I implemented such an algorithm myself. But as time went on, I decided to rewrite the code.
This is a C++ language small algorithm C++ implementation program, did not want to put here. However, when I want to implement such an algorithm, I want to find a ready-made one on the Internet, but there is no one that meets the needs. I had no confidence in the code I wrote when I was in college, so I decided to write a new one and put it here for readers. Also increase the number of clicks on BLOG.
The polygon in this algorithm refers to a closed simple polygon composed of a series of point sequences. Its beginning and end point may or may not be the same point (it is not mandatory that the beginning and end point be the same point). Such a polygon can be of any shape, including multiple edges in an absolute line. Therefore, define multilateralism
In order to speed up the speed of discrimination, the outer rectangle (rect_t) of the polygon is calculated first to determine whether the point falls within the outer rectangle. Only the points that meet the conditions within the outer rectangle can proceed to the next step of calculation. For this reason, the outer rectangular structure rect_t and the method vertices_get_extent within the outer rectangle of the set of points are introduced.
Int pt_in_poly (const vertex_t* vl, int np, / * polygon vl with np vertices * / const vertex_t* v) {int I, j, K1, K2, c; rect_t rc; vertex_t w; if (np
< 3) return 0; vertices_get_extent(vl, np, &rc); if (v->X
< rc.min_x || v->X > rc.max_x | | v-> y
< rc.min_y || v->Y > rc.max_y) return 0; / * Set a horizontal beam l (* v, w) from v to the ultra right * / W.x = rc.max_x + DBL_EPSILON; W.y = v-> y; c = 0; / * Intersection points counter * / for (iTun0; I {j = (iTun1)% np; if (is_intersect (vl+i, vl+j, v, & w)) {C++ } else if (vl [I] .y = = W.Y) {K1 = (np+i-1)% np; while (K1roomi & & VL [K1] .y = = w.y) K1 = (np+k1-1)% np; K2 = (iTun1)% np; while (K2roomi & & VL [K2] .y = = W.Y) K2 = (K2q1)% np; if (K1) = K2 & is_same (v, & w, vl+k1, vl+k2) = 0)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.