computational-geometry

Partitioning a set of points in 2D plane

风流意气都作罢 提交于 2021-01-28 11:56:07
问题 The problem statement is - "You are given a set of N points, where N is even and N <= 1000. You have to find the number of pairs of points, such that if you draw a line through that pair, each side of the line will contains equal number of points(N/2-1)." I can't figure out, how to solve this problem in O(n^2) or less time? Here is my brute-force solution- class Point{ public: int x, y; Point(){x = y = 0;} void make_point(int X, int Y){ x = X; y = Y; } int Point:: orientation (Point &p0,

Polygon from a grid of squares

萝らか妹 提交于 2021-01-27 06:39:39
问题 I'm looking for an algorithm to find the polygon that surrounds a contiguous grid of squares without holes as shown here: . I already have each of the grid squares storing data about the kind of edges with the surrounding area that they are composed of (i.e. top, top-right, top-bottom, no edges, etc.), so I'm thinking that this data could be utilized by the algorithm. If someone could provide some pseudocode for such an algorithm that would also be great. The input to the algorithm would be a

Polygon from a grid of squares

烈酒焚心 提交于 2021-01-27 06:38:30
问题 I'm looking for an algorithm to find the polygon that surrounds a contiguous grid of squares without holes as shown here: . I already have each of the grid squares storing data about the kind of edges with the surrounding area that they are composed of (i.e. top, top-right, top-bottom, no edges, etc.), so I'm thinking that this data could be utilized by the algorithm. If someone could provide some pseudocode for such an algorithm that would also be great. The input to the algorithm would be a

Area of Union Of Rectangles using Segment Trees

試著忘記壹切 提交于 2021-01-27 05:35:33
问题 I'm trying to understand the algorithm that can be used to calculate the area of the union of a set of axis aligned rectangles. The solution that I'm following is here : http://tryalgo.org/en/geometry/2016/06/25/union-of-rectangles/ The part I don't understand is : The segment tree is the right choice for this data structure. It has complexity O(logn) for the update operations and O(1) for the query. We need to augment the segment tree with a score per node, with the following properties.

Area of Union Of Rectangles using Segment Trees

拜拜、爱过 提交于 2021-01-27 05:35:25
问题 I'm trying to understand the algorithm that can be used to calculate the area of the union of a set of axis aligned rectangles. The solution that I'm following is here : http://tryalgo.org/en/geometry/2016/06/25/union-of-rectangles/ The part I don't understand is : The segment tree is the right choice for this data structure. It has complexity O(logn) for the update operations and O(1) for the query. We need to augment the segment tree with a score per node, with the following properties.

Find nearest edge in graph

跟風遠走 提交于 2021-01-20 16:35:19
问题 I want to find the nearest edge in a graph. Consider the following example: Figure 1: yellow: vertices, black: edges, blue: query-point General Information: The graph contains about 10million vertices and about 15million edges . Every vertex has coordinates. Edges are defined by the two adjacent vertices. Simplest solution: I could simply calculate the distance from the query-point to every other edge in the graph, but that would be horribly slow. Idea and difficulties: My idea was to use

Find nearest edge in graph

女生的网名这么多〃 提交于 2021-01-20 16:31:13
问题 I want to find the nearest edge in a graph. Consider the following example: Figure 1: yellow: vertices, black: edges, blue: query-point General Information: The graph contains about 10million vertices and about 15million edges . Every vertex has coordinates. Edges are defined by the two adjacent vertices. Simplest solution: I could simply calculate the distance from the query-point to every other edge in the graph, but that would be horribly slow. Idea and difficulties: My idea was to use

Find nearest edge in graph

本小妞迷上赌 提交于 2021-01-20 16:30:57
问题 I want to find the nearest edge in a graph. Consider the following example: Figure 1: yellow: vertices, black: edges, blue: query-point General Information: The graph contains about 10million vertices and about 15million edges . Every vertex has coordinates. Edges are defined by the two adjacent vertices. Simplest solution: I could simply calculate the distance from the query-point to every other edge in the graph, but that would be horribly slow. Idea and difficulties: My idea was to use

How to compute the mitered offset of a polygon using its Straight Skeleton

不羁的心 提交于 2021-01-02 19:10:00
问题 I have a Straight Skeleton algorithm implemented in Python and would like to use it to offset the edges of a polygon. I have seen several papers suggesting this offsetting approach unfortunately none of them provides specific information on how to achieve it. Among them: A CGAL implementation of the Straight Skeleton of a Simple 2D Polygon with Holes Since the very definition of a Straight Skeleton is based on the continuous wavefront or grassfire propagation of the edges, it is specially

How to compute the mitered offset of a polygon using its Straight Skeleton

我是研究僧i 提交于 2021-01-02 19:02:06
问题 I have a Straight Skeleton algorithm implemented in Python and would like to use it to offset the edges of a polygon. I have seen several papers suggesting this offsetting approach unfortunately none of them provides specific information on how to achieve it. Among them: A CGAL implementation of the Straight Skeleton of a Simple 2D Polygon with Holes Since the very definition of a Straight Skeleton is based on the continuous wavefront or grassfire propagation of the edges, it is specially