• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Bioq

Uniform distribution of points in a 2D convex hull

3 posts in this topic

Hi all,

Given a set of points N and a convex hull H, how can I place the points in N such that they are uniformly distributed in H? All points in N must be inside of H.

I'm defining uniform distribution in this case to be:
For each point p in N:
the minimum distance between p and (any other point in N OR the perimeter of H) = p_d

All p_d values should have minimal variance for N to be uniformly distributed in H.

I'm looking for a good balance between distribution and time complexity, so approximations are welcome! I'm only concerned about 2D for right now, but solutions that naturally extend to 3D would be awesome.

Thank you,
0

Share this post


Link to post
Share on other sites
This is a tricky problem. The first thing I would try is to throw the points in following a uniform random distribution and then iterate through the process of finding the closest pair of points and pushing both of them away from each other a little bit. See if you can get reasonable results with that.
0

Share this post


Link to post
Share on other sites
A Poisson disc would be perfect for your needs, as it specifically focuses on keeping a minimal distance between sample points. You'll still need to check intersection with the hull in case a point happens to fall outside it by chance.

Otherwise, if Poisson disc does not apply in your case for some reason or you are just looking for a more ghetto (or intuitive, depending on your perspective) solution, read on:

If you do not need perfect correctness (i.e. some points may be closer together and others may be further away, or in other words, the variance of the distance should be nonzero but not too large), then another probabilistic way to do it is to generate a regular point lattice with distance equal to your mean minimum distance, and displace each point in every dimension using a Gaussian distribution with your required variance? Like this:
[quote]
Let [eqn]\mu[/eqn] be the mean distance between each point, and [eqn]\sigma[/eqn] be the required variance.
1. Generate a regular lattice spaced by [eqn]\mu[/eqn] in every dimension.
2. For each point in the lattice:
- choose a random angle (or two, if you are in three dimensions) to displace the point in some direction in space
- generate a random variable [eqn]z[/eqn] following a Gaussian distribution* with your variance [u]but with mean 0[/u]
- displace the point by [eqn]z[/eqn] units in the direction determined by the angle chosen above
- if the point falls outside or too close to your convex hull, try again until it works (this is biased, but I think it's acceptable given that considering the shape of the hull would likely be intractable)

* see Box-Muller transform to get that from uniform variables
[/quote]

Some examples rendered with a throwaway program, with a mean [eqn]\mu = 1[/eqn] and a progressively higher variance (from 0 to 0.0003) - remember to square root the variance if you need the standard deviation:

[img]http://i50.tinypic.com/2mzyxbn.png[/img]

Obviously, as variance increases, the distribution tends to perfect uniformity (assuming an infinite lattice - if it is finite, the algorithm will degenerate).

The 3D situation is exactly the same, your lattice is now 3D and you are displacing the points according to two angles (spherical coordinates i.e. azimuth and elevation instead of just rotation in 2D), but you still only need one Gaussian distribution sample. Edited by Bacterius
1

Share this post


Link to post
Share on other sites
I need to insist on proper language: you want [b]Poisson disk sampling, [/b]not a [b]uniform distribution[/b] of points. In a uniform distribution, every point inside your polygon would be equally probable, with no consideration for their distances; your "uniform" property is actually called [b]low discrepancy[/b],

If you care a lot about equalizing distances between samples, you should start from the right number of uniformly distributed samples, build their Voronoi graph, and move them iteratively until each of them has satisfying distances from its closest neighbours (and maybe from the polygon edges or from samples outside the polygon). For example, you could pretend that the samples are material points and move them with forces computed from Delaunay edges: if they are shorter than the median they push and if they are longer than the median they pull.
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0