mercredi 1 mars 2023

How do I generate a random point within a set of lines in 3D space?

So, I have a list of 3D points that are connected to one another in the order that they were added to the list. The first and last points are also connected to ensure that the lines form a shape. How would I generate a random point within the lines if the only information I have is the X/Y/Z coordinates of the points and the order that they are connected?

I want to be able to fill simple shapes like this: star shape

and wonky shapes like this: wonky shape
(filled example)

and have them stay filled if the points in the list are rotated or moved.

I got it to work in 2D by generating a random number between the lowest and highest X/Z values and using the winding number algorithm to determine if the point was within the shape, but when I tried to make the shape bend/morph accordingly when a point moved in the third axis everything I tried barely worked and broke instantly when I tried to rotate it.

I don't have a lot of experience in math like this and I couldn't find anything online that would help me with this problem. After 5 days of struggling and bashing my head against a wall, I'm completely out of ideas. Any help is appreciated.




Aucun commentaire:

Enregistrer un commentaire