How would I constantly position a point above a ray?

38 Views Asked by At

my Vector math skills aren't top notch so I can't seem to figure out how to solve this problem.

I have a ray that goes from point [a, b] and I need a point to constantly be above that line by an offset of 2. So if the ray is directly horizontal the point will increase by 2 in the y direction, and if the ray is completely vertical they point will increase by 2 in the x direction. How could I accomplish this? Thank you.

1

There are 1 best solutions below

4
On BEST ANSWER

We can compute the normal line of the line that travels from $A(x_1,y_1)$ and $B(x_2,y_2)$ and then travel 2 units along the normal line.

First, verify that $$y=\frac{y_2-y_1}{x_2-x_1}(x-x_1)+y_1$$ travels through $A$ and $B$. Then the normal bisector is given by

$$y=\frac{x_1-x_2}{y_2-y_1}(x-\frac{x_1+x_2}{2})+\frac{y_1+y_2}{2}$$

So what we can do is travel 2 units along the normal bisector for the desired result. That may include solving a kind of ugly looking system of equations.

We want a point that is on the normal line and is also on the circle centered at $(\frac{x_1+x_2}{2},\frac{y_1+y_2}{2})$ with radius $2$. I drew a picture of this in desmos: https://www.desmos.com/calculator/ts12vjjknh.

enter image description here

We can find this point by solving the system of equations given below. Sorry for the change in notation in the equations below $(x_1,y_1)=(a,b)$ and $(x_2,y_2)=(c,d)$.

enter image description here