Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Continue vector vs plane intersection

Image

How to determine Ray (one point R(rx;ry) and alpha with OX) with line (two points A(ax;ay) and B(bx;by)) intersection?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

The line segment $AB = \{A + t(B-A) \in \mathbb R^2|t \in [0,1]\}$.

The ray $L = \{R+s(\cos(\alpha),\sin(\alpha))\in \mathbb R^2|s \in \mathbb R^+\}$.

Therefore the intersection $AB \cap L$ is the set of points $(x,y)$ that satisfy $$A + t(B-A) = R+s(\cos(\alpha),\sin(\alpha))$$ for some $t \in [0,1]$ and $s \in \mathbb R^+$. To solve this split it into components:

  • $A_x + t(B_x-A_x) = R_x+s\cos(\alpha)$
  • $A_y + t(B_y-A_y) = R_y+s\sin(\alpha)$

and solve both sides for $t$:

  • $t = \frac{R_x-A_x}{B_x-A_x}+s\frac{\cos(\alpha)}{B_x-A_x}$
  • $t = \frac{R_y-A_y}{B_y-A_y}+s\frac{\sin(\alpha)}{B_y-A_y}$

now we equate these to solve for $s$:

$$s = \frac{\frac{R_x-A_x}{B_x-A_x}-\frac{R_y-A_y}{B_y-A_y}}{\frac{\sin(\alpha)}{B_y-A_y}-\frac{\cos(\alpha)}{B_x-A_x}}$$

You can back substitute this to get $t$ and check that $t \in [0,1]$ and $s \in \mathbb R^+$ before back substituting to find the intersection point.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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