Poisson Disk distribution on hemisphere - disk

I just implemented Poisson Disk generation in the plane with this simple algorithm:
http://people.cs.ubc.ca/~rbridson/docs/bridson-siggraph07-poissondisk.pdf
Now I would like to generate a Poisson Disk distribution on the surface of a hemisphere (or better, on a part of the spherical surface, given a certain angle)
can anyone tell me an algorithm to do that?
Thanks!

Thanks thouis for your answer! i already found a solution before, so i'll poste it here for those who are interested:
first i create enough poisson disc samples in the unitsquare (enough means more than n)
then i sort those samples by the smaller coordinate (for example, a point (10,9), the smaller coordinate is 9 - another point (8,50) the smaller coordinate is 8 - the order of the points would be (8,50),(10,9) )
then i take the first n samples in the sorted list. due to the sorting mode, those samples will again lie in a square area. I then scale up the coordinates such that they lie again in the unit square. Now i have exactly n poisson disc samples in the unit square.
then I use the plane to sphere mapping described in http://www.cs.rutgers.edu/~decarlo/readings/mcrt-sg03c.pdf page 23 to get uniformly distributed samples on the spheresegment of an arbitrary area angle
works well for me

I would look at:
"Fast Poisson-Disc Sample Generation in n-Dimensional Space by Subdivision Refinement" by Gamito and Maddock. This should be fairly easy to extend to the sphere using "Rendering and managing spherical data with sphere quadtrees" by Fekete.

Related

Construct lines from multiple 2D points and measure the distance between those lines

Multiple points on a 2D plane are given. They represent a window frame of mostly rectangular form with some possible variations. The points which are part of each side are not guaranteed to form a perfect line. Each side of the window should be measured.
A rotating electronic device attached to a window measures the distance in all directions providing a 360 degree measurements. By using the rotation angle and the distance, a set of points are plotted on a 2D coordinate system. So far so good.
Now comes the harder part. The measured window frame could have some variations. The points should be converted to straight lines and the length of each line should be measured.
I imagine that the following steps are required:
Group the different points into straights lines. This means approximating each line “between” the points that form it.
Drawing those lines, getting rid of the separate points used to construct the lines.
Find the points where each two lines intersect.
Measure the distance between those points. However not all distances between all points are interesting. For example diagonals within a frame are irrelevant.
Any Java libraries dealing with geometry that could solve the problem are acceptable. I will write the solution in Kotlin/Java, but any algorithmic insights or code examples and ideas in any other languages or pseudo code are welcome.
Thank you in advance!
New Image
I would solve this in 2 stages:
Data cleaning: round the location (X, Y) of each point to its nearest multiple of N (vary N for varying degrees of precision)
Apply the gift-wrapping algorithm (also known as Jarvis March)
You now have only those points that are not co-linear, and the lines between them, and the order in which they need to be traversed to form the perimeter.
Iterate over the points in order, take point Px and P(x+1), and calculate the distance between them.

Find n points, equally dividing k points among each other on a map.

I have 'k' fixed cameras, I have their geo-coordinates,
and when I receive a geo-location coordinate of an object from a radar I need to PTZ track the detected object using the camera nearest to the object.
calculating distance of all objects detected from each camera to find the nearest one is slow when the number of cameras is large.
I need to reduce latency, and am thinking of introducing 'n' points located adequately, (grouping cameras into n groups) to first decide which group of cameras to begin calculating for.
I don't know how to find these n points, and what a good number for 'n' is?
Build Voronoi diagram for camera positions.
Determine what cell object belongs to (using trapezoidal decomposition or other methods) - camera for that cell is the closest.
I finally was able to solve using 2D nearest neighbor search algorithm.
Voronoi Diagram generation, and then Trapezoidal decomposition seemed to vertical a hill to climb.
Very informative links :
1. http://bl.ocks.org/llb4ll/8709363 and
2. http://nns.tume-maailm.pri.ee/

Optimally filling a 3D sphere with smaller spheres

I'm trying to optimally fill a 3D spherical volume with "particles" (represented by 3D XYZ vectors) that need to maintain a specific distance from each other, while attempting to minimize the amount of free space present in-between them.
There's one catch though- The particles themselves may fall on the boundary of the spherical volume- they just can't exist outside of it. Ideally, I'd like to maximize the number of particles that fall on this boundary (which makes this a kind of spherical packing problem, I suppose) and then fill the rest of the volume inwards.
Are there any kinds of algorithms out there that can solve this sort of thing? It doesn't need to be exact, but the key here is that the density of the final solution needs to be reasonably accurate (+/- ~5% of a "perfect" solution).
There is not a single formula which fills a sphere optimally with n spheres. On this wikipedia page you can see the optimal configurations for n <= 12. For the optimal configurations for n <= 500 you can view this site. As you can see on these sites different numbers of spheres have different optimal symmetry groups.
your constraints are a bit vague so hard to say for sure but I would try field approach for this. First see:
Computational complexity and shape nesting
Path generation for non-intersecting disc movement on a plane
How to implement a constraint solver for 2-D geometry?
and sub-links where you can find some examples of this approach.
Now the algo:
place N particles randomly inside sphere
N should be safely low so it is smaller then your solution particles count.
start field simulation
so use your solution rules to create attractive and repulsive forces and drive your particles via Newton D'Alembert physics. Do not forget to add friction (so movement will stop after time) and sphere volume boundary.
stop when your particles stop moving
so if max(|particles_velocity|)<threshold stop.
now check if all particles are correctly placed
not breaking any of your rules. If yes then remember this placement as solution and try again from #1 with N+1 particles. If not stop and use last correct solution.
To speed this up you can add more particles instead of using (N+1) similarly to binary search (add 32 particles until you can ... then just 16 ... ). Also you do not need to use random locations in #1 for the other runs. you can let the other particles start positions where they were placed in last run solution.
How to determine accuracy of the solution is entirely different matter. As you did not provide exact rules then we can only guess. I would try to estimate ideal particle density and compute the ideal particle count based on sphere volume. You can use this also for the initial guess of N and then compare with the final N.

Perlin\Fractal noise jump for just one unit between values

First of all sorry for my pour english.
I'm trying to make virtual world with terrain just like in simcity2000 or transport tycoon where terrain is made from tiles and tile heights can't jump more than one level between tiles, so there is no cliffs.
For terrain generation I'm using perlin\simplex noise but I'm getting to stiff slopes with that.
I've took a look on the source code of Open Transport Tycoon, and there after terrain generation all tiles on map are looped through and smoothed out to have elevation for just one unit.
But it won't work this way for me, because my map will be much bigger and I cannot afford smoothing all of it by loop. Also it's not possible to smooth just the visible part of terrain , because it will be different depending on from which tile smoothing was started.
I've tried to write my own noise function which is returning linearly interpolated value between two points with distance equal to max height of those points, that way slope can't be more than 45 degree, it worked but until you try to sum such functions together.
How can I pseudo-randomly generate terrain with mountain slopes of max 45 degrees, and aproach this other way than just smoothing out some previously generated map?
Right now I'm out of ideas, and hoping that Perlin noise may have some possible option like "max slope angle", but google didn't help me with that.
Perlin noise is inherently slope-limited, since the values within each grid cell are interpolated between four gradients that all have slope 1/gridSize (or some other fixed value depending on your implementation).
If you generate a limited number of octaves with a fairly wide grid relative to your tile size, you should be able to find a scaling factor experimentally that ensures a maximum slope of 1.

computer vision: extracting info about a shape given a contour (e.g. pointy, round...)

Given the 2D contour of a shape in the form of lines and vertices, how can I Extract Information from that?
like: Pointy, round, straight line.
Shape similarities with a given shape.
Code is not necessary, I am more interested in
concepts and the names of techniques involved to
guide my search....
Thanks in advance.
Image moments
One approach is to calculate the first and second order central moments of the shape described by the 2D contour. Using these values the elongation of the object can be calculated.
The central image moments can be combined to the seven moments of Hu, which are invariant to change in scale, rotation and translation (ie. they are very good for basic shape recognition). (More on image moments here).
Unitless ratio of perimeter and area
An other approach is to calculate the length of the perimeter (p) and the size of the inscribed area (a). Using these two values, the following ratio can be computed:
ratio = p^2 / (4 * pi * a)
The closer this ratio is to one, the more circle like is the described shape.
Other methods
Fourier descriptors
Ratio of shape area and the area of the convex hull of the shape
Another method of contour shape classification is topological aproach based on the "size function" That could be useful for global shape recognition, but not for extracting "local" features like pointy/round/straight.
http://en.wikipedia.org/wiki/Size_function
Basically slicing contour by parametrized line and counting number of connected components depending on parameter.
http://www.ingre.unimo.it/staff/landi/articoli/patrec.pdf
What I think you might be looking for is often called Blob or Connectivity Analysis, which I believe was first developed at SRI (Stanford Research Institute). Image moments are one component of this area.

Resources