Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8142265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:45:30+00:00 2026-06-06T12:45:30+00:00

I am looking for an algorithm to generate equally distributed points inside a polygon.

  • 0

I am looking for an algorithm to generate equally distributed points inside a polygon.

Here is the scenario:

I have a polygon specified by the coordinates of the points at the corners (x, y) for each point. And I have the number of points to generate inside the polygon.

For example lets say I have a polygon containing 5 points: (1, 1) ; (1, 2) ; (2, 3) ; (3, 2) ; and (3, 1)

And I need to generate 20 equally distanced points inside that polygon.

Note: Some polygons may not support equally distributed points, but I’m looking to distribute the points in a way to cover all the region of the polygon with as much consistency as possible. (what i mean is I don’t want a part with a lot more points than another)

Is there an algorithm to do so? or maybe a library

I am working on a C# application, but any language is ok, since I only need the algorithm and I can translate it.

Thanks a lot for any help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T12:45:32+00:00Added an answer on June 6, 2026 at 12:45 pm

    The simple approach I use is:

    1. Triangulate the polygon. Ear clipping is entirely adequate, as all you need is a dissection of the polygon into a set of non-overlapping triangles.

    2. Compute the area of each triangle. Sample from each triangle proportionally to the area of that triangle relative to the whole. This costs only a single uniform random number per sample.

    3. Once a point is determined to have come from a given triangle, sample uniformly over the triangle. This is itself easier than you might think.

    So really it all comes down to how do you sample within a triangle. This is easily enough done. A triangle is defined by 3 vertices. I’ll call them P1, P2, P3.

    1. Pick ANY edge of the triangle. Generate a point (P4) that lies uniformly along that edge. Thus if P1 and P2 are the coordinates of the corresponding end points, then P will be a uniformly sampled point along that edge, if r has uniform distribution on the interval [0,1].

      P4 = (1-r)*P1 + r*P2

    2. Next, sample along the line segment between P3 and P4, but do so non-uniformly. If s is a uniform random number on the interval [0,1], then

      P5 = (1-sqrt(s))*P3 + sqrt(s)*P4

    r and s are independent pseudo-random numbers of course. Then P5 will be randomly sampled, uniform over the triangle.

    The nice thing is it needs no rejection scheme to implement, so long, thin polygons are not a problem. And for each sample, the cost is only in the need to generate three random numbers per event. Since ear clipping is rather simply done and an efficient task, the sampling will be efficient, even for nasty looking polygons or non-convex polygons.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for an algorithm to find the common intersection points between 3 spheres.
I am looking for an algorithm that will generate a series of colors so
what method/algorithm does iis 7 use to generate etags. I'm looking for exact, not
I am looking for an algorithm to generate pseudo random numbers in a three
I'm looking for an algorithm to generate permutations of a set in such a
I'm looking for an algorithm which can generate a short (fx 16 chars (not
I've been looking for a simple Java algorithm to generate a pseudo-random alpha-numeric string.
I want to generate positive random semi-definite matrices. I am looking for an algorithm
I'm looking for an algorithm to generate all permutations with repetition of 4 elements
I am looking for a good algorithm to generate nice major/minor tick intervals for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.