I'm trying to replicate the following geogebra simulation for an n-sided polygon. Simulation Sample At the moment the simulation is hard coded meaning that the vertices of the pentagon are individually rotated about the respective points.
This is a problem because I'm trying to do the same for n-sided polygon, where the user has the ability to change n. Since the points about which each triangle is rotated are dynamic and dependent on the rotation of the previous triangle, how do I go about doing this?
I feel like I need a transformation matrix, but feels like it 's complicated. How should I think about this? Does it actually need to be hard-coded?
This is the exact simulation I'm looking to replicate.Simulation Sample 2 Even here every rotation has been hard coded to exhaust all possibilities for n. They have hard coded the rotation for 8 vertices, which is the max for n.
I have tried various methods but I've found that without predefined points about which the relative rotations have to be made, the rotations don't work out. And I can't predefine these points, because they are dynamic, and rotating themselves.