| ▲ | cluckindan a day ago |
| Generate random points inside a square (trivial), mirror one half by the diagonal (preserves distribution), transform coordinates inside the resulting triangle to the given triangle. |
|
| ▲ | Etherlord87 a day ago | parent | next [-] |
| Not square, rectangle. The article speaks of a parallelogram but you can the distribution will be the same for the rectangle. |
| |
|
| ▲ | mytailorisrich a day ago | parent | prev | next [-] |
| That's essentially the accept-flip method of the article, isn't it? |
| |
| ▲ | cluckindan a day ago | parent [-] | | Not really. Using a parallelogram means each x-coordinate’s allowed range depends on the y-coordinate and vice versa, but using a square, the coordinates are independent. |
|
|
| ▲ | saltcured a day ago | parent | prev | next [-] |
| Wouldn't that subsequent transform distort the sample distribution? As you make the angle at one vertex more obtuse, the density of the point mapping increases more there relative to the points near the other, more acute vertices. |
| |
| ▲ | atq2119 a day ago | parent | next [-] | | Affine transformations don't change relative density. You can think of it this way. There's a density function on the shapes in question. Whenever you transform the 2d space, you have to adjust the density at the same time to preserve "volume" (area times density). Non-linear transforms, such as interpreting a square as polar coordinates to obtain a disk, will expand or shrink area differently in different parts of the space, which means that if you start with a uniform density, you end up with a non-uniform density. But linear/affine transforms affect area the same everywhere in the space, and so if the density is uniform to begin with, it remains uniform. | | |
| ▲ | saltcured a day ago | parent [-] | | Thanks, I should have reminded myself that my intuitions are often non-mathematical. I don't even know how I decided that a change in angle would have a non-linear effect on density. I also had an intuition that the aspect ratio change would squish the distribution. I guess this aspect ratio doesn't matter for the density distribution of dimensionless points. But, if doing something like splatting a pixel/sprite at each point coordinate, would the sprite shape need to be transformed to match...? |
| |
| ▲ | hatthew a day ago | parent | prev [-] | | I believe an affine transformation would keep density perfectly consistent across the whole area. |
|
|
| ▲ | emil-lp a day ago | parent | prev [-] |
| You mean inside the resulting rectangle? That's what the article suggests. |
| |
| ▲ | aaronblohowiak a day ago | parent [-] | | no, this person is not suggesting a parallelogram but rather performing an affine transformation on the triangle to make it a right triangle so they can pick a random point in a square instead. as another commenter mentioned, I believe this distorts the distribution and won't do the right thing. | | |
| ▲ | creata a day ago | parent | next [-] | | https://en.wikipedia.org/wiki/Probability_density_function#V... Affine transformations just scale the probability density by a constant, so a uniform distribution is still uniform. | | |
| ▲ | aaronblohowiak a day ago | parent [-] | | ah, excellent point. thanks. this works if they are transforming the triangle to be a right triangle to make a rectangle but if they are making it half a square, that could not be accomplished solely with affine transformations (if I figure correctly...) | | |
| ▲ | cluckindan 18 hours ago | parent [-] | | But you can just map one right triangle to the other without affecting the distribution. |
|
| |
| ▲ | o11c a day ago | parent | prev [-] | | There's no distortion for the purposes of randomness (there would be if you cared about distance between specific points before/after the transformation), but the blog article fails to actually explain the method. Clicking through to SO explains it (but assumes you can read numpy). The `s * u` and `t * v` (where `u` and `v` are vectors) are the transformation from right-triangle (half of square) to triangle (half of parallelgram). | | |
| ▲ | saltcured a day ago | parent [-] | | Hmm, is this "car(ing) about distance between specific points" something that would matter if we were going to operate in reverse and splat something at each point to render the triangle? I think that sort of splatting is how I intuitively think about this problem, and likely where I went wrong in thinking there would be a distortion of the density function. I'm not confident whether this actually matters though. Would it still approximate the same distribution regardless of what splat shape is used...? |
|
|
|