Specific functions are mentioned in your second example so "the" is indeed grammatical. But see edit below.
Your first example involves a less defined concept. Do all people feel the same way? Can a single person have different feelings about safety? How about different degrees of intensity of feeling? Your example implicitly recognizes that "feeling of safety" may not describe a single emotion, but rather may describe an unspecified one of a range of emotions, by using "a." It is grammatical and, to this speaker of American English, idiomatic.
EDIT: I did not mean to imply disagreement with FumbleFinger's comment that "the function of panning" may be grammatical but is not idiomatic (at least not idiomatic in American English). He is correct that "the panning function" is more idiomatic. I do disagree with him that "a feeling of safety" is not idiomatic or common if indeed he is even implying that. I was only trying to distinguish between the use of definite and indefinite article in the examples as they were presented.