Experimenting with vertical aligned trapezoid filler. Use points 1 & 3 to control the x length of trapezoid, points 2 & 4 only have y values Center fill not working at extreme ratios. Most quads in a lot 3d engines are actually coplanar trapezoids (eg: flat textured tiled floors, walls and ceilings but not complex mesh like Suzanne), so I hope this can be optimized. This happens as raycasters and voxel engines are based on a tiled 2d map. Regular 2 triangles based quads in scratch, have a drawCount of 28 while trapezoids have drawCount of 15. This projects calculations assumes vertical edges are parallel & first edge is the base1 to simplify variable assignment & calculations Next up investigate @sakura_neko outstanding quad method https://scratch.mit.edu/projects/604763772
Still a lot of raw blocks but less if/else statement branching and less overall assignments The 3d engine know which is base1 based on the z index of the vertex. So don't waste the filler time sorting what's already known. This add some optimizations by reducing assignments 1. Don't calculate edge lengths 2. Use supplementary angle rule for parallel lines 3. Use tan of bisecting angle of each point for slope 4. Use goto to get point where 2 bisecting angles intersect to get bisecting ratio of radius to reduce variable assignments by 4 (Update This is just the opposite bisecting angle, so don't need to calculate intersection any longer) 5. Remove the 4 ox[1-4] assignments as we can derive those values from trapezoid length 6. Use slopes of non parallel edges to get inner triangle intersection 7. Use trigonometry to get inner triangle non-base lengths for inRadius/area calculation 8. Use quad bisector slopes to get centroid of triangle Other areas for optimization: In a tiled plane if you calculate one angle, and you can infer 3 other complimentary angles in adjoining tiles & edge lengths value are shared by 1 adjoining trapezoid. This method should scale pretty well if you associate previously calculated values with current trapezoid. Similarly for 3d cubes which also use trapezoids, the interior angles are complimentary to angles in the other faces. Maybe transpose the values to allow rotation with move and set direction like but the focus this project was on this vertical aligned trapezoids. Thx to for their excellent project and logic description from of their filler