I want calculate the reflection from a straight R on the surface from the straight BC:

enter image description here

The triangle with the position vectors A,B,C are given. As well the position vector P and the direction vector R.

what I can calculate:

Now I can calculate the intersection point D(x,y) and the reflection vector (as a direction vector R') and I know the x coordinate from the point P'(x,?) because the x value from the point P and P' are equals.

what I cannot calculate:

I need from the point P' the y coordinate. Because I need position vectors for drawing the reflected line with python matplotlib.

How can I get the y coordinate from the point P' with the given parameters?

The reflected vector will go from D(x,y) to P'(x,y)

matplotlib reflection

Thanks you!

  • $\begingroup$ How do you know that $x' = x$? ...And what is $A$ for? It looks like you only need the line $BC$. $\endgroup$ – mr_e_man Sep 5 '18 at 14:17

It seems that you have already solved the problem of reflection, so we can ignore everything except the point $\mathbf D$ and vector $\mathbf R',$ which you have computed, and the desired result $\mathbf P' = (x_P, y_{P'}),$ where $x_P$ is the $x$-coordinate of $P$ and is already given.

Take the coordinates $\mathbf D = (x_D,y_D)$ and $\mathbf R' = (r'_x, r'_y).$ The line in the direction $\mathbf R'$ from $\mathbf D$ then can be described by the equations \begin{align} x &= x_D + tr'_x,\\ y &= y_D + tr'_y,\\ \end{align} where $t$ is a variable real number.

You can then find the value of $t$ that will given you the point $\mathbf P'$ by solving this equation: $$ x_P = x_D + tr'_x. $$ Everything here is known except $t,$ so this is a simple linear equation to solve: $$ t = \frac{x_P - x_D}{r'_x}.$$

Take this value and plug it into the formula for $y$: $$ y_{P'} = y_D + tr'_y. $$

For some ways of setting up this problem, you could get a negative value of $t,$ for example if $\mathbf P$ was much further to the left and the vector $\mathbf R$ pointed downward to the right instead of to the left to reach $\mathbf D.$ In that case there would not be a valid solution, and a good diagram would confirm that there cannot be one. But in the figure as you have drawn it, $t$ will be positive.

  • $\begingroup$ Hello David K Thanks you for your great explaination and your investet time. I implemented your recommended solution and it works total fine. @Ross Millikan Thanks you also! $\endgroup$ – helmi Sep 5 '18 at 21:09

Work in polar coordinates with $D$ as the origin. You can compute the angle that BC lies at. If you add or subtract (depending on which end of $BC$ you choose) $\frac \pi 2$ you get the angle of the normal, which leaves $D$ in an upward right direction perpendicular to $BC$. Call a point on it $N$. Then use angle of incidence equals angle of reflection. You have $\angle PDN=\angle NDP'$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.