Hi everybody,
I need to find a way to determine if a ray is pointing at a line.
I have a line defined by two points [(x,y),(x,y)]. The line continues infinitely in both directions.
I have a startPoint (x,y) as the start of the ray and an endPoint which is just a point on the ray.
How can I determine if the ray is pointing at the line?
I will give more context to the question:
It is for a program I'm writing.
The line represents a wall, startPoint is a point where a robot is starting to move from and endPoint is where the robot is currently at.
I want to know if by continuing on the same path as created between the points will the robot eventually reach the wall.
true for will reach the wall.
false for will not reach the wall.
some examples:
for a line [{ x: 200, y: 100 },{ x: 450, y: 100 }]
startPoint { x: 300, y: 150 }, endPoint { x: 500, y: 150 } - expected false
startPoint { x: 300, y: 150 }, endPoint {x: 400, y: 250 } - expected false
startPoint { x: 400, y: 250 }, endPoint {x: 300, y: 150 } - expected true
for a line [{ x: 200, y: 100 },{ x: 200, y: 400 }]
startPoint { x: 300, y: 150 }, endPoint {x: 400, y: 250 } - expected false
startPoint { x: 500, y: 150 }, endPoint {x: 300, y: 150 } - expected true
for a line [{ x: 450, y: 400 },{ x: 550, y: 200 }]
startPoint { x: 300, y: 150 }, endPoint {x: 400, y: 250 } - expected true
startPoint { x: 300, y: 150 }, endPoint { x: 500, y: 150 } - expected true
I need help with the right equations for this problem.
Thanks
I need to find a way to determine if a ray is pointing at a line.
I have a line defined by two points [(x,y),(x,y)]. The line continues infinitely in both directions.
I have a startPoint (x,y) as the start of the ray and an endPoint which is just a point on the ray.
How can I determine if the ray is pointing at the line?
I will give more context to the question:
It is for a program I'm writing.
The line represents a wall, startPoint is a point where a robot is starting to move from and endPoint is where the robot is currently at.
I want to know if by continuing on the same path as created between the points will the robot eventually reach the wall.
true for will reach the wall.
false for will not reach the wall.
some examples:
for a line [{ x: 200, y: 100 },{ x: 450, y: 100 }]
startPoint { x: 300, y: 150 }, endPoint { x: 500, y: 150 } - expected false
startPoint { x: 300, y: 150 }, endPoint {x: 400, y: 250 } - expected false
startPoint { x: 400, y: 250 }, endPoint {x: 300, y: 150 } - expected true
for a line [{ x: 200, y: 100 },{ x: 200, y: 400 }]
startPoint { x: 300, y: 150 }, endPoint {x: 400, y: 250 } - expected false
startPoint { x: 500, y: 150 }, endPoint {x: 300, y: 150 } - expected true
for a line [{ x: 450, y: 400 },{ x: 550, y: 200 }]
startPoint { x: 300, y: 150 }, endPoint {x: 400, y: 250 } - expected true
startPoint { x: 300, y: 150 }, endPoint { x: 500, y: 150 } - expected true
I need help with the right equations for this problem.
Thanks