I am trying to calculate the reflection of a line on a surface in OpenCV.
I work with a projectile im tracking which is drawing line 2 and a border.
I "just" want to draw a line of the bounce angle as you can see in my drawing.
I got a code that calculate the angle of three given points but in my example line 2 is not static. It will move because its drawn by a moving projectile. So to calculate this i need the intersection point of the border and Line 2. Im kinda struggeling to get that..
Is there an easy way to solve this ?
Thank you.
CodePudding user response:
From your comment:
Projectile coordinates (P0)
(center_x, center_y)
Impact point (P1)
(predicted2[0], predicted2[1])
Border extremes (A, B)
(Ax, Ay), (Bx, By)
I assume that P1 belongs to the segment AB.
You should project P0 in the straight line passing by A, B. Call this point PP. You should then compute
arctan(distance(PP,P1)/distance(P0,PP))
This is equal to alpha, that you can use to compute the reflection segment, depending on how long it is.
I suggest to use the shapely library: