Skip to Main Content Skip to Search
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Doug’s Pick of the Week

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.


Video Content

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


Doug Hull is an Application Engineer at The MathWorks. A MATLAB user since 1994, he gets paid to live, eat, and breathe MATLAB! This blog is dedicated to promoting the File Exchange by highlighting files and original video content.



  • Tim Davis: Oh, I’m a bit dyslexic. The code has a variable “west” that should be called...
  • Tim Davis: The fix is to replace the max(diff(r)) line with: [ignore b] = sortrows ([diff(r') a(p(r(1:end-1)))']) b =...
  • Tim Davis: Matt, Good point, thanks for catching that. I missed that in the problem statement. It’s easy to...
  • Matt Fig: Tim, There is a problem in your second code. In the case when a zero block is the same size as a non-zero...
  • Moran: Hi Chris, I tried everything I could think of, and have sent several observations about this bug to support,...
  • odessit: Hello, I have compiled standalone application with deploytool. It would work fine, but the error is in...
  • Duane Hanselman: FYI… % strmatch replacements % strmatch is obsolete, strncmp and strcmp are built in % case...
  • Doug: Duane, I just looked, I did not see an m-lint warning against STRMATCH in 2008a. However, I seem to recall what...
  • hashem: Hi Doug, I built a GUI and write a help for it in “chm” (compiled HTML file) format, and I...
  • Tim Davis: I left out the comments in the code, above. Most of the functions should be familiar to most MATLAB users....

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

Related Topics