I have a cube of unit length. Each face of the cube is divided into 10 x 10 segments. Consider an object of size equal to that of a segment moving through the surface of the cube.
I need to compute a way to find the next segment in the cube given the direction of the object.
I would say to simply use flatten representation. Navigation within a face is simple. Navigation between faces can easily coded using a map of "relations":
BTW, you can use any suitable net:
Depending on exactly what you're trying to do, you could express/convert position and direction vectors into spherical coordinates on the unit sphere (ie radius = 1), and then project onto the cube. The projection may cause an inconstant perceived velocity however, but it may or may not be objectionable in your case.
For example, convert the spherical position coordinates back to carthesian, then figure out the associated cube sides and face coordinates as shown here: http://www.nvidia.com/object/cube_map_ogl_tutorial.html (see section Mapping Texture Coordinates to Cube Map Faces), which you can then snap to your 10x10 segments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With