Tuesday, August 3, 2021

String of Triangles

I want to draw a poly-line instead, two of them actually, one in the north and another in the south. Then I want to subdivide one of the two by grabbing three points and making a simple triangle. Or several...

Next step in making polygons...

I split the world rectangle into two better polar polygons. I still need to figure out further polygon subdivision, and then subdivide many times. The simplest approach is to take three consecutive points which define a triangle unless the points are all in a line, which is possible. If it is in line, then the triangle has zero area and I can detect and ignore it. Better, I can detect and remove or reposition the middle point! Furthermore, I can turn four consecutive points into a quad or triangle pair; I can turn any number of points into a triangle mesh inside of a polygon! 

After we create upper and lower polar polygons we can find several consecutive points, at least three, to start defining polygons. This is a loop with two legs, upper and lower, between the initial endpoints. In a triangle this third point gets between the endpoints on the bottom or lower leg, but for other polygons we want the upper leg to have all the points on or above a line between the endpoints and all the points in the lower leg lie below a line between the endpoints. Also, we need to go through the bottom leg backwards to build a list of polygon points. What do I need?

  1. Start with triangles, look for three consecutive points

  2. Check this triangle for area. If the area is very low, move that midpoint! 8-)

  3. Modify the northern and southern polygons as needed

  4. Eventually figure out how to build bigger polygons

Monday, August 2, 2021

Better Polar Polygons!

I will subdivide the world rectangle into two polar polygons, The page creates a northern polygon from some point on the left at x = 0 to some point on the right at x = 520. The remaining portion of the world rectangle becomes a southern polygon.

More Polygon Subdivision

I wrote some code last night to create polygons. One was a triangle fan around a point and the other was basically another triangle fan around the north pole. What this tells me is that making that polygon on a world map is subdividing that world into two new polygons. I can dog-walk a line across my world rectangle from west to east to create two north and south polar polygons, like I ham-fistedly did with the second bit of code last night, or subdivide the second larger polygon from the first triangle fan into a second and third polygon. I could do a better world map with that line dog-walked truly chaotically from west to east to subdivide the world into two polar polygons and then push a loop dog-walked through either the north or south polar polygon, by doubling back over a section of the polygon border.

  1. Split the world rect with a line of points into two polygons.

  2. Split one of these with a loop of points doubling back adjacent to a bit of polygon border

  3. Rinse and repeat several times; each subdivision divides an existing polygon, adds one

North Polar Poly Landmass

Then the page creates a northern polygon from some point on the left at x = 0 to the polygon, around the northern edge to some point on the right at x = 520. The remaining portion of the world rectangle becomes a southern polygon.

Sunday, August 1, 2021

Making polygons in my world rectangle

I will subdivide the world rectangle into polygons, starting with the first one... Then the page creates a northern polygon from some point on the left at x = 0 to the polygon, around the northern edge to some point on the right at x = 520. The remaining portion of the world rectangle becomes a southern polygon.

Stitching up some polygons...

I vegged out today and did nothing at all. I need to get my words in and post something, then get to bed... I want to use requestAnimationFrame() to march some triangles through my map, and then march some random triangles to pick landmass. How do I handle this? I know how I split up a grid of squares, rectangles, quads or pixels. I can randomly subdivide some latitude and longitude quads into triangle pairs, top left and bottom right or top right and bottom left. Top triangles will be defunct in the top row and bottom triangles will be defunct in the bottom row.

I don’t want that, so I need to figure out something else. That something else is I have the page create a polygon in the form of a triangle fan around the north and another around the south pole. I then have the page create polygons between these two north and south polar polygons. I can pick a random point on the northern polygon and randomly walk a dogleg down to the southern polygon, follow that around the southern polygon a few points and then back up to the northern polygon. This stitches up a third polygon and by default defines a fourth polygon. I need to go see if I can make this work...