It doesn't know so the initial orientation is arbitrary. You have to set the "up" direction by touching the ball with a magnet in the right spot (there's a reed switch inside) and rotating it around the Z (vertical) axis until the directions are correct.