Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identifiying the next point on the surface of a cube

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.

like image 684
Mahadevan Sreenivasan Avatar asked Feb 14 '23 11:02

Mahadevan Sreenivasan


2 Answers

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":

enter image description here

BTW, you can use any suitable net:

enter image description here

like image 152
Renat Gilmanov Avatar answered Feb 17 '23 01:02

Renat Gilmanov


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.

like image 36
Der Schmale Avatar answered Feb 17 '23 01:02

Der Schmale