3D math to calculate position
Posted on 2003-12-10
I don't know much about 3d engines and related math so this might be a simple problem. I need to calculate the position of an object (x,y,z) in a 3D environment depending on the dimensions of the environment and the number of other object already occupying said environment.
I want the objects placed into the environment to have the largest distance between other objects and the edges of the environment. For example, we have an "empty" 3D cube 300 pixels by 300px by 300px. When I place 1 object into the environment it needs to find the position that is furthest away from the edges and other objects. In this case it would be at x=0,y=0,z=0 (assuming the origin is in the center of the cube). If I now place a second object into the environment it should let me know what the position of the 2 object present are. I assume this will be:
What kind of math do I need to achieve this? Assuming the environment is square or rectangular & objects do not occupy any space.
I would also further be interested to know how this calculation changes when object have a preset size (i.e. two balls, one r=30px the other r=60px). Thank you.