Results 1 to 40 of 72

Thread: normal at corner of rectangular

Threaded View

  1. #12
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: normal at corner of rectangular

    Yup, using your implementation on a triangle you'll tend to accumulate points around P1, since you're taking x1 and x2 small. Luckily I seem to have a magical intuition about what you want--I don't really know how, but I did figure you wanted a more-or-less uniform distribution, and noticed your method wasn't going to give it to you.


    To get a more uniform distribution, use truly random numbers as I originally suggested. In VB (6.0) just use the Randomize/Rnd() functions to get x1 and x2 each between 0 and 1, and plug those into the formula. Generate as many random pairs (x1, x2) as you wish and plug them each into the formula to get a new random point.

    If you're interested in getting a truly uniform distribution of random points on an arbitrary triangle, I could figure out the underlying distribution of x1 and x2 that you'd need, but I'm pretty sure that's not where you're going. I could also give a method of "blanketing" the triangle with a uniform grid, but that'd be complicated to think through.

    The above paragraph is for a triangle; for a parallelogram, if you simply used uniformly spaced x1 and x2 from 0...1 you'd get both of the above properties. That is, use x1 = 0, 0.2, 0.4, 0.6, 0.8, 1, x2 = 0, 0.2, 0.4, 0.6, 0.8, 1, instead of what you're using which is x1 = 0.5, 0.33, 0.25, 0.20, 0.17, 0.14, ..., 1/n, x2 = 0.5, 0.33, 0.25, 0.20, 0.17, 0.14, ..., 1/m. Using this type of spacing of x1 and x2 for a triangle would also give an approximately uniform result. At the least, the points wouldn't accumulate around the corners nearly as dramatically.
    Last edited by jemidiah; Mar 17th, 2009 at 08:05 AM.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width