Thanks for your response and code snippet!
As of now, I have solved the initial problem of finding the points, using the following code:
However, I would like to improve this function s.t. the obtained points do not cut corners as much as they do now. I will make a new post for this problem and link it here.