Tracking the orientation of a 3d object and the mouse pointer

guys is there any way I can track and record the orientations of a 3d model and the pointer being worked on in blender
as I am trying to create a algorithm for shading and painting a model faster so I need to track the orientations of the object and the mouse pointer

I am really new to using blender , if this is a really beginner question I apologize
any help is much appreciated