Wednesday, June 2, 2021

Quads, Octahedra and Snaky Continents, Oh My! 8-P

There’s a ‘new’ thing, at least compared to the way I obsess about triangles and more complex polygons, triangle fans really; turning lines into quads by pushing out both sides from the line midpoint, or half quads by pushing out from only one side, all based of delta x and delta y (and delta z, but that would make an octahedron, and an excursion into 3D space I want to do for basic world polyhedrons, they subdivide quite nicely into 48 sided spherical polyhedrons, as well as limbs for critter body shapes). The half quad makes a decent facsimile of an equilateral triangle, good enough for my purposes, by pushing the third corner away from the midpoint by midpoint x plus P0.y-P1.y and midpoint y plus P0.x-P1.x. We get a quad by pushing the midpoint out, mx+my-P0.y, my+mx-P1.x and mx+my-P1.y, my+mx-P1.x. The triangle half quad is the way I’d get a facing for two points in my list of the two feet of a biped, with the tail ‘facing’ the other way, a backing or rearing…

I can use a string of points to make a line which makes a dog leg across some map, make quads between each successive pair of points, subdividing each quad into a triangle pair or into a triangle fan around the midpoint. We can connect adjacent quads by making triangles between the joint and adjacent outer points, or make a pair of triangles there and push the new midpoint between the adjacent outer points to be the ‘right’ distance from the joint. This could be used to make a snake body, limb or tentacle, or make a snaking continent around the joint points and midpoints.

The ‘limb model’, if you will, could be used make continents with peninsulas sticking out, and we can find some way to quickly and easily fill up the ‘sea’ tiles of a map once we are done defining land, mostly by connecting to the sides and partitioning the sea into a row of quads further subdivided into triangle pairs along the closest diagonal corners. We will want to double check the top and bottom row of points to make sure subsequent points are each further from the origin and close off ‘concavities’ (where Javascript dutifully makes overlapping quads!) with a nice triangle bridging this. That means we would have a ‘spine’ and an upper and a lower shore line each connects with the top and bottom of the map and makes at least one upper and lower row of quads, again each quad subdivided into a triangle pair. This can easily be a nice world rectangle which we can quickly wrap around a globe making a spherical polyhedron with half of the polar triangles collapsing down out of existence. We can hang on to them anyway, just to go back and forth between a globe and a world rectangle, and calculate triangle areas based on the XYZ coordinates of the spherical polyhedron.

It occurs to me that a triangle snake would be a lot easier; start with three points to make our initial triangle, then the next point makes an adjacent triangle off of the closest side. We continue until we reach the other side of the map rectangle, which might be our world map or world rectangle, making an upper and lower coastline as we go, for when we want to subdivide the rest of the rectangle into useful rows of quads, again closing off ‘concavities’. A snake of ten triangles which doesn’t quite reach from one side to another might have an upper row of eleven columns and a lower row of twelve, each deep enough to want to subdivide into double rows for a total of thirty-three upper and thirty-six lower triangles for a total of seventy-nine, or thirty-three if we want to keep it simple. We can push out triangles and chains of triangles to make peninsulas.

No comments:

Post a Comment