Sunday, September 19, 2021

Yesterdays’ bit was waaaay too complicated, let’s dial it back some, dongma? Get two points, one 100 pixels to the right of the first and use p0 and p1 to derive p2 with dx and dy, where p2 is midpoint x minus dy and midpoint y plus dx; it gets more complicated, as complicated as you want, but this is a point at right angles to the line or vector p0 to p1. Vector A is p0 to p1, vector B is p0 to p2 and the cross product is negative because this is clockwise, B is left of A. I can draw a nice almost equilateral, making a div shaped by these three points, and then another off of the vector p0 to p2…

We are using the cross product to detect clockwise orientation and we can step through this with a button, eventually overlapping the first div to establish we can make a triangle fan this way. We can detect overlap when the cross product of the first and last vectors goes from negative to positive and then back to negative again as we swing around past it. Once this happens we have the page discard the last point and start building a new triangle fan around a point which we generate outside of the first div, pushing this new center point out from the open outer edge of the triangle div. It has the vectors pNth to p2 and pNth to p1 and pushes point pNth+1 on around in a clockwise fashion.

At this point, or at least after we make an adjacent triangle fan, we need to change the rules a bit. We are building out triangle fan polygons off of the open edges of a polygon made up of these two triangle fans and we need to take adjacent edges into account. We can take any random point on this larger polygon and find the points on either side of it to make two vectors and find out if they make something convex or concave, which will determine how we proceed. If concave, we find a new TF center by pushing out through the midpoint of the edge between the first and last points; if convex, we push out from the center point, make our new triangle fan polygon and add it to the larger polygon, rinse and repeat. A problem which I have been working on for months… Sigh


No comments:

Post a Comment