In fact, you do not need triggers for this. Just use slopes or change the values ββin x and y .
For the slope line m = y/x line perpendicular to this line has a slope of -1/m or -x/y .
The slope of m between the red dots is -150/150 or -1/1 . I noticed that your positive y points down.
Therefore, the positive slope is 1/1 . Both of your x and y change at the same speed with the same amount.
Once you know this, then everything should be pretty easy to understand. Since they are aligned at an angle of 45 degrees, the aspect ratio of the triangle 45-45-90 is 1 : 1 : sqrt(2) . Therefore, if your length is 20 , the individual change in x and y will be 20/sqrt(2) or roughly 14 in integers.
So, your two yellow dots will be at (36, 236) and (64, 264) . If the lines are not aligned to a convenient degree, you will need to use arctan() or something similar, and get the angle between the line and the horizontal line so that you can determine the ratio of x and y changes.
I hope my answer was not too difficult to follow. For a more general solution, see Troubadour's answer.
Edit: Since the OP says that the bottom red dot actually rotates around the top red dot, we need a more flexible solution.
I am going to extend this answer from Troubadour since I am doing the same. Please refer to his message when you read mine.
1. Get the vector from the source (200, 100) to the rotating point (50, 250):
vector = (200 - 50, 100 - 250) = (150, -150)
2. Rotate the vector, replacing x and y and negate x to get a new vector:
vector = (150, -150) => swap => (-150, 150) => negate x => (150, 150)
3. Get the unit vector (length 1) from the new vector:
vector = vector / length(vector) = (150 / length(vector), 150 / length(vector)) ~= (0.7071, 0.7071) where length(vector) = sqrt(150^2 + 150^2) ~= 212.2320
4. Get a displacement vector of length 20 by multiplying the unit vector.
displacement_vector = vector * 20 = (0.7071 * 20, 0.7071 * 20) = (14.1421, 14.1421)
5. Add / subtract this vector to / from your rotating vector (point):
yellow_1 = (50, 250) + (14.1421, 14.1421) ~= (64, 254) yellow_2 = (50, 250) - (14.1421, 14.1421) ~= (36, 236)
I hope that the above steps will help you formulate your code. It doesn't matter what its angle is, the same steps.