computational-geometry

Is point inside polygon?

白昼怎懂夜的黑 提交于 2019-12-02 10:13:10
I need to write a function that will calculate if a point is inside polygon (true/false). Polygon always contains 4 points. I'm reading polygons and points from SVG file <g id="polygons"> <g id="LWPOLYLINE_183_"> <polyline class="st10" points="37.067,24.692 36.031,23.795 35.079,24.894 36.11,25.786 37.067,24.692 " /> </g> <g id="LWPOLYLINE_184_"> <polyline class="st10" points="35.729,23.8 35.413,23.516 34.625,24.39 34.945,24.67 35.729,23.8 " /> </g> <g id="LWPOLYLINE_185_"> <polyline class="st10" points="34.483,24.368 33.975,23.925 34.743,23.047 35.209,23.454 34.483,24.368 " /> </g> <g id=

How to produce an ordered sequence of vertices of polygon from a discretized cellular representation of polygon

半腔热情 提交于 2019-12-02 10:06:52
Here is the cellular representation of polygon shown:- Here is the extracted polygon shown. We are given the input as a matrix polM that stores 1 for pink cells and 2 for yellow cells. From the yellow colored cells we want to create a polygon. This is also done using below code derived from here . clear; close all; A=ones(25,25); indices=[64,65,88,89,90,91,111,112,113,114,115,116,117,135,136,137,138,139,140,141,142,143,158,159,160,161,162,163,164,165,166,167,168,169,182,183,184,185,186,187,188,189,190,191,192,193,194,195,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,232,233,234

Sort point list into polygon

妖精的绣舞 提交于 2019-12-02 08:27:18
问题 I have a set of points. This set of points do define a (non convex) polygon but its not ordered. Since it's not ordered I cannot just draw from point to point to draw its border. How can I sort it in a way I can walk through this point list and draw a polygon? My first idea was to use a convex hull but my polygons are, most of the time, concave. 回答1: I don't think there's a well-defined solution to this. Consider five points like this: . . . . . What polygon would be correct here? 回答2: You

Sort point list into polygon

白昼怎懂夜的黑 提交于 2019-12-02 08:01:01
I have a set of points. This set of points do define a (non convex) polygon but its not ordered. Since it's not ordered I cannot just draw from point to point to draw its border. How can I sort it in a way I can walk through this point list and draw a polygon? My first idea was to use a convex hull but my polygons are, most of the time, concave. I don't think there's a well-defined solution to this. Consider five points like this: . . . . . What polygon would be correct here? You have to order the points so you walk around the polygon with the interior on your left (or right) as you move from

Boundary enclosing a given set of points

女生的网名这么多〃 提交于 2019-12-02 06:07:52
问题 I am having a bit of a problem with an algorithm that I am currently using. I wanted it to make a boundary. Here is an example of the current behavior: Here is an MSPaint example of wanted behavior: Current code of Convex Hull in C#:https://hastebin.com/dudejesuja.cs So here are my questions: 1) Is this even possible? R: Yes 2) Is this even called Convex Hull? (I don't think so) R: Nope it is called boundary, link: https://www.mathworks.com/help/matlab/ref/boundary.html 3) Will this be less

Show that, given a query point q, it can be tested in time O(log n) whether q lies inside P

喜欢而已 提交于 2019-12-02 05:17:28
问题 I am trying to solve some exercises of the book "Computational Geometry Algorithm and Applications, 3rd - de berg et al" of chapter 6 - Point Location. Unfortunately, I have no idea how to solve the following exercise: Given a convex polygon P as an array of its n vertices in sorted order along the boundary. Show that, given a query point q, it can be tested in time O(log n) whether q lies inside P. My Idea so far: The only way I know to determine if a point lies inside p in O(log n) is to

find which tetrahedral element a point belongs to

梦想的初衷 提交于 2019-12-02 05:04:01
I have a tetrahedral mesh of a 3d region. The mesh is defined by two files with extensions .node and .ele which contain data related to nodes and elements (this is the format of output files from tetgen, the 3d Delaunay tetrahedralization program). The .node file contains in each line the node number and the x,y,z co-ordinates of that node. The .ele file contains the element number and node numbers corresponding to its four vertices. Now, given any point (x1,y1,z1), what is the easiest algorithm to decide which element this point belongs to? If you know the orientation of the faces of your

How to determine which side of a polygon edge is inside a polygon, and which is outside?

白昼怎懂夜的黑 提交于 2019-12-02 02:19:47
I have an edge of a polygon (convex or concave). I want to find out if, going straight from start to end point of that edge, I have to turn right or left to get inside or outside of polygon. How can I check that? Traverse the whole polygon in that direction. If you find that you went clockwise, then the interior is to the right; if you went counter-clockwise, it's to the left. Another approach: Project a perpendicular line and count how many times it crosses other edges. odd -> interior zero or even -> exterior Equivalently If you happen to have a well optimized point-in-polygon routine

Boundary enclosing a given set of points

江枫思渺然 提交于 2019-12-02 02:10:43
I am having a bit of a problem with an algorithm that I am currently using. I wanted it to make a boundary. Here is an example of the current behavior: Here is an MSPaint example of wanted behavior: Current code of Convex Hull in C#: https://hastebin.com/dudejesuja.cs So here are my questions: 1) Is this even possible? R: Yes 2) Is this even called Convex Hull? (I don't think so) R: Nope it is called boundary, link: https://www.mathworks.com/help/matlab/ref/boundary.html 3) Will this be less performance friendly than a conventional convex hull? R: Well as far as I researched it should be the

How to determine which side of a polygon edge is inside a polygon, and which is outside?

爱⌒轻易说出口 提交于 2019-12-02 02:04:44
问题 I have an edge of a polygon (convex or concave). I want to find out if, going straight from start to end point of that edge, I have to turn right or left to get inside or outside of polygon. How can I check that? 回答1: Traverse the whole polygon in that direction. If you find that you went clockwise, then the interior is to the right; if you went counter-clockwise, it's to the left. 回答2: Another approach: Project a perpendicular line and count how many times it crosses other edges. odd ->