# In SIFT, how is the coordinate system being rotated?

I need to understand how SIFT calculates the descriptors for the keypoints.

Intuitively, I understand that it takes each keypoint, calculates the gradients for each pixel in a neighborhood of the keypoint, and that's basically the descriptor for the keypoint. The paper mentions a coordination system rotation in the keypoint, I assume this is when the image is rotated, the keypoint descriptor doesn't change.

My question:

I'm following this implementation of SIFT. In the part of the calculation function, there is this cos/sin calculation: I think this is related to the coordinate system rotation. Can you explain how the coordinate system is being rotated? Why does that have to do with the hist_width?