Algorithm: Some points on the plane, how to find a point around the nearest lap?

Source: Internet
Author: User

Some point on the plane, how to find a point around the nearest lap
Like some coordinate points.
(from)
(2,2)
(3,1)
(3,3)
(4,2)
(6,2)

To look for (4,2) around the point, underline the plane coordinates to see, should be dot
(2,2)
(3,1)
(3,3)
(6,2)
How to implement the algorithm


SYY64 (Pacific) () Reputation: 145 Blog 2007-3-19 14:05:08 Score: 0



Ask all points to a certain distance, according to the distance from small to large judgment, in a certain threshold for the desired point.


xyliang230 () () Reputation: 2007-3-19 14:16:20 score: 0


If there is (2,1) this point is counted.
Because it is drawn to the plane, there is no other point between it and the (4,2) point.


Program
Finally, these closest points are connected together into a polygon.


Mackz (in Mutual) () Reputation: 117 Blog 2007-3-19 14:41:06 score: 0



A person's judgment is not the same as a computer, and strict rules must be given in the procedure. For example, the nearest point, either only one, or a few points of the distance is the same, or give a range, only "recent" definition. In short, there must be a mathematical definition, which is why the programming to learn the cause of mathematics.


He_hawk (Strong) () Reputation: 2007-03-20 08:52:41 score: 0


Yes, the establishment of the data model is very important, the model up, the program will be written out, the system will come out.
There is no good idea of dealing with this problem now,

If there are many points on the plane, there are several situations:
1, find a point of its surrounding the nearest point, and now around to determine the four direction of each to find a nearest point and then these points (recently found four, such as Point is in a corner, it may be two) connected can be drawn into a face, less than four points, the point A is also connected together.

2, at the same time looking for two points around the nearest point, is to connect the two points, respectively, find each point around three the nearest point of the direction, two points connected in this direction do not find, this is six points (such as the two points have on the edge of the situation, the connection into the picture will be on the edge of the point also connected)

3, at the same time to find a number of points around the nearest point, but also to find out the nearest points around these points, and then find the boundaries of these points, how to find the boundary. Use PtInRegion to determine whether a point is in each face (a polygon connected to the nearest point around it), so that the two intersecting faces are merged, and the points in the polygon are no longer drawn.

To do this first, look at the help as if there is no way to determine whether two polygon polygons intersect. Can only judge by their own points.


He_hawk (Strong) () Reputation: 2007-03-20 09:15:46 score: 0


This example is available in the Help
Graphics graphics (HDC);

Point points[] = {
Point (110, 20),
Point (120, 30),
Point (100, 60),
Point (120, 70),
Point (150, 60),
Point (140, 10)};

Rect rect (65, 15, 70, 45);
GraphicsPath path;
SolidBrush SolidBrush (Color (255, 255, 0, 0));

Path. AddClosedCurve (points, 6);

Create a region from a path.
Region pathregion (&path);

Create a region from a rectangle.
Region rectregion (RECT);

Update the region to the portion this intersects with another region.
Pathregion.intersect (&rectregion);

Graphics. FillRegion (&solidbrush, &pathregion);
I don't know if it works.








Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.