Doug’s MATLAB Video Tutorials

March 11th, 2008

Practical Example: Placing a sampling grid in a polygon

A while back, I posted a video about how to place points randomly inside of an arbitrary polygon. [Click here] This video prompted a question about how to place points in a more systematic manner. If you are only allowed to change the edge length of an equilateral triangular grid, how can you get a set number of points into a given polygon. This is the first in a two part series on how to do that. This video focuses on how to generate the grid. The second video will cover how to vary the edge length until the goal of getting a set number of points into the polygon is reached.
iconFiles.jpgiconPod.jpg

4 Responses to “Practical Example: Placing a sampling grid in a polygon”

  1. Johnny replied on :

    Doug, great example, but there’s a math error in your code…ySpace should be ‘ySpace = e*sin(60)’ instead of ‘ySpace = e/sin(60)’.
    Thanks!

  2. Doug replied on :

    Johnny,

    Oops, I never noticed because when E = 1 it just does not matter.

    Good catch!

    Thanks,
    Doug

  3. Juliane replied on :

    What i would like to know is how can you automate a label method for the generated samples in a sppecified direction

  4. Doug replied on :

    Juliane,

    I am not sure what you mean. Please be more specific.

    Doug

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Doug Hull is a proud MathWorker who is on a mission to help you with MATLAB.

Doug's picture

These postings are the author's and don't necessarily represent the opinions of The MathWorks.