computational-geometry

Mathematically producing sphere-shaped hexagonal grid

扶醉桌前 提交于 2019-11-30 13:28:29
问题 I am trying to create a shape similar to this, hexagons with 12 pentagons, at an arbitrary size. (Image Source) The only thing is, I have absolutely no idea what kind of code would be needed to generate it! The goal is to be able to take a point in 3D space and convert it to a position coordinate on the grid, or vice versa and take a grid position and get the relevant vertices for drawing the mesh. I don't even know how one would store the grid positions for this. Does each "triagle section"

shortest paths & geodesics

[亡魂溺海] 提交于 2019-11-30 12:41:44
问题 given a mesh made entirely of quads, where every vertex has valence n (with n >= 3), and does not lie on the same plane, I need to find the distance of every vertex in the mesh from a closed set of seed vertices. That is, given one or more mesh vertices (a seed set), I need to build a distance map that stores the distance of each mesh vertex from the seed set (which will have distance 0 from themselves). after spending some time searching for possible solutions, I got the following picture: 1

What's a good library to do computational geometry (like CGAL) in a garbage-collected language?

主宰稳场 提交于 2019-11-30 12:31:56
I need a library to handle computational geometry in a project, especially boolean operations, but just about every feature is useful. The best library I can find for this is CGAL , but this is the sort of project I would hesitate to make without garbage collection. What language/library pairs can you recommend? So far my best bet is importing CGAL into D. There is also a project for making Python bindings for CGAL, but it's very incomplete. I would still recommend to proceed with Python and the existing Python binding. When you find it's incomplete, you'll also find that it is fairly easy to

Intersection of N rectangles

荒凉一梦 提交于 2019-11-30 12:25:35
问题 I'm looking for an algorithm to solve this problem: Given N rectangles on the Cartesian coordinate, find out if the intersection of those rectangles is empty or not. Each rectangle can lie in any direction (not necessary to have its edges parallel to Ox and Oy) Do you have any suggestion to solve this problem? :) I can think of testing the intersection of each rectangle pair. However, it's O(N*N) and quite slow :( 回答1: Observation 1: given a polygon A and a rectangle B, the intersection A ∩ B

How can I test if a point lies within a 3d shape with its surface defined by a point cloud?

不羁岁月 提交于 2019-11-30 12:00:50
I have a collection of points which describe the surface of a shape that should be roughly spherical, and I need a method with which to determine if any other given point lies within this shape. I've previously been approximating the shape as an exact sphere, but this has proven too inaccurate and I need a more accurate method. Simplicity and speed is favourable over complete accuracy, a good approximation will suffice. I've come across techniques for converting a point cloud to a 3d mesh, but most things I have found have been very complicated, and I am looking for something as simple as

How to find out Geometric Median

你说的曾经没有我的故事 提交于 2019-11-30 11:21:33
问题 The question is: Given N points(in 2D) with x and y coordinates, find a point P (in N given points) such that the sum of distances from other(N-1) points to P is minimum. This point is commonly known as Geometric Median. Is there any efficient algorithm to solve this problem, other than the naive O(N^2) one? 回答1: I solved something similar for a local online judge once using simulated annealing. That was the official solution as well and the program got AC. The only difference was that the

Maximum possible number of rectangles that can be crossed with a single straight line

混江龙づ霸主 提交于 2019-11-30 10:58:41
问题 I found this challenge problem which states the following : Suppose that there are n rectangles on the XY plane. Write a program to calculate the maximum possible number of rectangles that can be crossed with a single straight line drawn on this plane. I have been brainstorming for quite a time but couldn't find any solution. Maybe at some stage, we use dynamic programming steps but couldn't figure out how to start. 回答1: Here is a sketch of an O(n^2 log n) solution. First, the preliminaries

Nesting maximum amount of shapes on a surface

孤者浪人 提交于 2019-11-30 10:32:37
问题 In industry, there is often a problem where you need to calculate the most efficient use of material, be it fabric, wood, metal etc. So the starting point is X amount of shapes of given dimensions, made out of polygons and/or curved lines, and target is another polygon of given dimensions. I assume many of the current CAM suites implement this, but having no experience using them or of their internals, what kind of computational algorithm is used to find the most efficient use of space? Can

Check If there exists a Circle

徘徊边缘 提交于 2019-11-30 10:23:55
问题 I was asked this during a Google Interview. We are given a string consisting of letters- F,L,R. - which is the instruction a robot follows F- goes forward by one step. L-turn left. R- turn right. String length can be upto 2500 characters. The string runs itself infinite times. We need to tell if there exists a circle with a radius, r( r can be any real number), such that the robot never leaves the circle. I was stuck at this point.I thought of using convex hull, but how to check it for

Validity of algorithm for creation of a non self-intersecting polygon

ⅰ亾dé卋堺 提交于 2019-11-30 10:11:17
As an extension and partial answer to my thread I wrote a simple algorithm that given a set of points(with xy coordinates) can form a non self-intersecting polygon. Claim: Given an arbitrary set of points with different coordinates it is always possible to construct a regular or irregular, non self-intersecting polygon. The algorithm: Assume there is a set V containing all the vertices 1) Sort all vertices in V by x-coordinate 2) Imagine a straight line (we'll call that "the divider") parallel to the x-axis which starting from the first node expands to infinity and divides/splits the vertices