Monday, September 6, 2021

No, I didn’t work on the novel all weekend… so I’m just going to get my words in, copy and paste a post to the blog and go to bed! (On the next page…)

I can make the oval-shaped world polygon and fill the polygon with random points which are inside of the oval, which is actually a circle, but twice as wide… so when I get a random width, minus the center point, I divide the x position in half. Actually, x position is already in unit circle distances and width is +/- pi, while height is 0 to pi but I think of it as +/- 90 or +/- ½ pi. Anyway, I can then find the closest point to each sequential pair of points in my world peach polygon to start building my triangle mesh. We make a list of open inner triangle edges and start going through them to find the nearest point or edge to make some more triangles. If the inner open edge already exists, then we know that two triangles are adjacent and we map them as adjacent so that they refer to each other through that unique edge. These initial outer triangles each pair up with another one, wrapping around edge to edge across the seam of my world peach. Each edge shares a triangle and it belongs with two different vectors which run clockwise around the triangle; each edge is a pair of vectors useful for building up complex polygons from a mesh of individual triangles.

So each triangle is a set of three points and three edges which are open or closed, three other possible adjacent triangle neighbors. Each edge has a length, which we can use to calculate the area of the triangle using Heron’s formula or get it with the dot product. The cross product could be used to find if a point is inside or outside of a given triangle, and therefore find points outside with which to build adjacent triangles. Or I can use the atan2 function to get the angle in radians. But I can probably, possibly, get away with pairing up the closest points and adjacent sides. If a point is closer to some edge on one triangle and is also closer to the nearest edge of the next outer triangle, then make that triangle. There won’t be, otherwise that point would probably have been the closest point to one of those two adjacent outer triangles. 

  1. Make a list of points for my oval world peach polygon. (already done)

  2. Make outer triangles which pair off, wrapping around left to right and right to left.

  3. Each triangle has three points, listed in clockwise order, three edges, three neighbors and an area.

  4. Make a list of edges and use this to pair up triangles, referencing the triangle neighbors in clockwise order, closing open edges as we find them and removing closed edges from a list of open edges as we find them; also adding open edges as we make triangles.

  5. Look for points to pair up with open edges to make new triangles, checking triangles and removing now closed edges as we make more triangles while adding open edges.

  6. Continue until we close off all the open edges and have made a closed triangle mesh.

No comments:

Post a Comment