computational-geometry

What is the algorithm for finding the center of a circle from three points?

余生颓废 提交于 2019-11-27 18:31:14
I have three points on the circumference of a circle: pt A = (A.x, A.y); pt B = (B.x, B.y); pt C = (C.x, C.y); How do I calculate the center of the circle? Implementing it in Processing (Java). I found the answer and implemented a working solution: pt circleCenter(pt A, pt B, pt C) { float yDelta_a = B.y - A.y; float xDelta_a = B.x - A.x; float yDelta_b = C.y - B.y; float xDelta_b = C.x - B.x; pt center = P(0,0); float aSlope = yDelta_a/xDelta_a; float bSlope = yDelta_b/xDelta_b; center.x = (aSlope*bSlope*(A.y - C.y) + bSlope*(A.x + B.x) - aSlope*(B.x+C.x) )/(2* (bSlope-aSlope) ); center.y =

Computational complexity and shape nesting

浪子不回头ぞ 提交于 2019-11-27 18:25:45
问题 I have SVG abirtrary paths which i need to pack as efficiently as possible within a given rectangle(as less waste of space as possible). After some research i found the bin packing algorithms which seems to be dealing with boxes and not curved random shapes(my SVG shapes are quite complex and include beziers etc.). AFAIK, there is no deterministic algorithm for actually packing abstract shapes. I wish to be proven wrong here which would be ideal(having a mathematical deterministic method for

How to find convex hull in a 3 dimensional space

亡梦爱人 提交于 2019-11-27 18:24:19
Given a set of points S (x, y, z) . How to find the convex hull of those points ? I tried understanding the algorithm from here , but could not get much. It says: First project all of the points onto the xy-plane, and find an edge that is definitely on the hull by selecting the point with highest y-coordinate and then doing one iteration of gift wrapping to determine the other endpoint of the edge. This is the first part of the incomplete hull. We then build the hull iteratively. Consider this first edge; now find another point in order to form the first triangular face of the hull. We do this

Java - Draw a ruler (line with tick marks at 90 degree angle)

♀尐吖头ヾ 提交于 2019-11-27 18:20:34
问题 I'm using Java AWT to draw lines on a panel ( Line2D and Graphics2D.drawLine() ) and I'm wondering how I can draw a line with tick marks, similar to: |----|----|----|----|----| I know the positions I'd like to draw the ticks at in advance. The lines could be in any position, so the ticks must be drawn at an angle releative to the line itself. My basic geometry & ability to apply it in Java is failing me. :) 回答1: I suggest you implement a ruler-drawing-method that draws a simple horizontal

find overlapping rectangles algorithm

血红的双手。 提交于 2019-11-27 17:53:15
问题 let's say I have a huge set of non-overlapping rectangle with integer coordinates, who are fixed once and for all I have another rectangle A with integer coordinates whose coordinates are moving (but you can assume that its size is constant) What is the most efficient way to find which rectangles are intersecting (or inside) A? I cannot simply loop through my set as it is too big. Thanks edit : the rectangles are all parallel to the axis 回答1: Personally, I would solve this with a KD-Tree or a

Nearest Neighbor Searching using Voronoi Diagrams

早过忘川 提交于 2019-11-27 16:13:39
问题 I've successfully implemented a way to generate Voronoi diagrams in 2 dimensions using Fortune's method. But now I'm trying to use it for nearest neighbor queries for a point (which is not one of the original points used to generate the diagram). I keep seeing people saying that it can be done in O(lg n) time (and I believe them), but I can't find a description of how it's actually done. I'm familiar with binary searches, but I can't figure out a good criteria to guarantee that upper bound. I

Path generation for non-intersecting disc movement on a plane

…衆ロ難τιáo~ 提交于 2019-11-27 14:42:23
What I'm looking for I have 300 or fewer discs of equal radius on a plane. At time 0 each disc is at a position. At time 1 each disc is at a potentially different position. I'm looking to generate a 2D path for each disc for times between 0 and 1 such that the discs do not intersect and the paths are relatively efficient (short) and of low curvature if possible. (for example, straight lines are preferable to squiggly lines) Lower computation time is generally more important than exactness of solution. (for example, a little intersection is okay, and I don't necessarily need an optimal result)

Generate new polygons from a cut polygon (2D)

北城以北 提交于 2019-11-27 13:11:46
问题 I'm stuck with this little problem and my algorithm to solve this doesn't hold for all cases. Does anybody has an idea how to solve this? Here's an example polygon: example http://img148.imageshack.us/img148/8804/poly.png Formal description We have a list of points in CW order defining the polygon. We also can query whether a point is a cutting point with is_cut(p) , where p is a given point. Now we want to compute new polygons caused by this "cut". The algorithm should do this: Input: {a, c1

Convex hull of 4 points

断了今生、忘了曾经 提交于 2019-11-27 13:09:31
问题 I would like an algorithm to calculate the convex hull of 4 2D points. I have looked at the algorithms for the generalized problem, but I wonder if there is a simple solution for 4 points. 回答1: Take three of the points, and determine whether their triangle is clockwise or counterclockwise:: triangle_ABC= (A.y-B.y)*C.x + (B.x-A.x)*C.y + (A.x*B.y-B.x*A.y) For a right-handed coordinate system, this value will be positive if ABC is counterclockwise, negative for clockwise, and zero if they are

Getting a bounded polygon coordinates from Voronoi cells

爱⌒轻易说出口 提交于 2019-11-27 13:09:01
问题 I have points (e.g., lat, lon pairs of cell tower locations) and I need to get the polygon of the Voronoi cells they form. from scipy.spatial import Voronoi tower = [[ 24.686 , 46.7081], [ 24.686 , 46.7081], [ 24.686 , 46.7081]] c = Voronoi(towers) Now, I need to get the polygon boundaries in lat,lon coordinates for each cell (and what was the centroid this polygon surrounds). I need this Voronoi to be bounded as well. Meaning that the boundaries don't go to infinity, but rather within a