computational-geometry

Concave Hull implementation

本小妞迷上赌 提交于 2019-12-06 16:29:37
I am trying to implement the algorithm described in the following http://repositorium.sdum.uminho.pt/bitstream/1822/6429/1/ConcaveHull_ACM_MYS.pdf I am using the following class libraries. Loyc libs come from http://core.loyc.net/ using System; using System.Collections.Generic; using System.Linq; using System.Device.Location; using Loyc.Collections; using Loyc.Geometry; using Loyc; Here is the basic class public class Hulls { private static List<Point<double>> KNearestNeighbors(List<Point<double>> points, Point<double> currentPoint, int k, out int kk) { kk = Math.Min(k, points.Count - 1); var

Find the biggest rectangular area consisting only of 2 types of letter in a given MxN board

若如初见. 提交于 2019-12-06 15:38:41
Possible duplicate: find largest submatrix algorithm I need help with a problem. Given a MxN board represented with M letters (a-z) in each of the N lines, i have to find the biggest area in which there are only 2 types of letters in it. The area must have rectangular shape. Here's an example : 4x4: AAAA ABBC BBCA DCAA The output will be 6, because the biggest rectangular area in which there are only 2 types of letters is in the upper corner AAA-ABB, there are only A and B (2 types). Some ideas: I think you will have to do an exhaustive search. However, once you have found a rectangle of area

Ideas for generating random lobulated pulmonary nodule contours

时光怂恿深爱的人放手 提交于 2019-12-06 14:32:45
I need to generate random lobulated contours such as the following Any ideas or algorithms on how to do this ?? The software I am going to use is matlab, however I have no problem if you post solutions in other languages too... p.s I only need to plot a random contour that resembles the above... How about this? degree = 5; numPoints = 1000; blobWidth = 5; theta = 0:(2*pi)/(numPoints-1):2*pi; coeffs = rand(degree,1); rho = zeros(size(theta)); for i = 1:degree rho = rho + coeffs(i)*sin(i*theta); end phase = rand*2*pi; [x,y] = pol2cart(theta+phase, rho+blobWidth); plot(x,y) axis equal set(gca,

Multi-dimensional segment trees

笑着哭i 提交于 2019-12-06 14:02:33
问题 The problem I have to solve is the 4D version of the 1D problem of stabbing queries: find which intervals a number belongs to. I am looking for a multi-dimensional implementation of segment trees. Ideally, it will be in Java and it will use fractional cascading. Multi-dimensional implementations exist for kd-trees (k-NN searches) and range trees (given a bounding box, find all points in it) but for segment trees I've only found 1D implementations. I'd be happy to consider other data

ImageJ - How to import and display a mesh?

放肆的年华 提交于 2019-12-06 13:28:02
问题 How can one open and display a mesh (either using the .obj, .stl or .dxf formats) on ImageJ? I have tried to open the files through file/open but got nothing displaying using the 3DViewer or the Interactive 3D Surface Plot plugins? I did get the list on the image below when I opened the obj... I had a look at the tutorials and this paper. 回答1: I guess you opened it using ImageJ's File->Open command. You should instead open the 3D Viewer first and click on File->Import surfaces->Wavefront (for

Set up linear programming code in Matlab to obtain vertices in 4D or higher dimensions

若如初见. 提交于 2019-12-06 11:14:09
Suppose I have a point cloud given in 4D space, which can be set up arbitrarily dense. These points will lie on the surface of a polytope, which is an unknown object at this point. (Just to provide some unhelpful visualization, here is a rather arbitrary projection of the point cloud which I have given - i.e. plotting the first 3 columns of the 100000x4 array): My goal is to obtain the vertices of this polytope, and one of my numerous attempts to get those was computing the convex hull of the point cloud. The problem here was that the number of resulting vertices differed with the specified

Error on drawing Fibonacci in web

こ雲淡風輕ζ 提交于 2019-12-06 09:57:38
问题 Currently I have this fiddle from Blindman67 which draws Golden spiral figure 1(see image below). function renderSpiral(pointA, pointB, turns){ var dx, dy, rad, i, ang, cx, cy, dist, a, c, angleStep, numberTurns, nTFPB, scale, styles; // clear the canvas ctx.clearRect(0, 0, ctx.canvas.width,ctx.canvas.height) // spiral stuff a = 1; // the larger this number the larger the spiral c = 1.358456; // constant See https://en.wikipedia.org/wiki/Golden_spiral angleStep = Math.PI/20; // set the

How to test if a line intersects a convex polygon?

被刻印的时光 ゝ 提交于 2019-12-06 09:37:27
Assume you are given the equation of a line (in 2d), and the equations of lines that form a convex polygon (the polygon could be unbounded). How do I determine if the line intersects the polygon? Furthermore, are there computational geometry libraries where such tasks are pre-defined? I ask because I'm interested not just in the 2D version but n-dimensional geometry. For the 2D case, I think the problem simplifies a bit. The line partitions the space into two regions. If the polygon is present in only one of those regions, then the line does not intersect it. If the polygon is present in both

Ray-triangle intersetion

情到浓时终转凉″ 提交于 2019-12-06 08:13:45
How can I test intersesion ray and triangle, and if it exist how to get distance from ray origin to intersection point?? What optimization I can use, if in my program I've got to check 1 ray to ~10000 triangles ?? A single polygon-ray intersection test is trivial and just involves making sure that the ray crosses at least one side of it (check them individually) or across the plane defined by the triangle between the sides of it. The optimization comes into not checking against polygons that the ray has no chance at all of crossing. Depending on how high of a dimension you're working in, how

Visibility of polygons from an edge

孤街醉人 提交于 2019-12-06 07:59:11
Given is a 2D are with the polygons. I need to find out the polygons visible in a perpendicular line of sight from the a given line segment lying within that area. e.g. Further, What can be the optimizations when the polygons have only vertical and horizontal edges. I'd suggest the following ... Rotate the problem so your 'line of sight' segment is aligned to the x axis. Find the (axis aligned) bounding rectangle (BR) of each polygon. Sort the polygons using the Y coordinate of the bottom edge of each BR Create a clipping 'range buffer' to mark the portions of the viewing segment that will be