Original post:
I am trying to find the outer vertices of a convex polygon (relative to point P outside the polygon). At the moment, I am only interested in rectangles (however, I need an algorithm that works with any convex polygon).

My plan is to build a line from the outer point P to the center point C. From this link line, I will build lines from point P to points 1 , 2 , 3, and 4 . Since points 2 and 4 will have the largest (most positive) and smallest (most negative) angles from the reference line, they will be identified as the outermost vertices.
Is this the best algorithm to work with? How to calculate angles from a reference angle (preferably in Java)?
Update to clarify:

I drew the lines (link bar in red). As you can see, the line from P to 2 creates the largest angle on one side of the reference line, and the line from P to 4 creates the largest angle on the other side. Therefore, these are the outermost peaks.
Peter
source share