We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Mathematics
- Geometry
- Jim Beam
- Discussions
Jim Beam
Jim Beam
Sort by
recency
|
9 Discussions
|
Please Login in order to post a comment
I've got a question: Suppose Jim is at (0,0), the mirror is at (0,2) and the wall goes from (0,1) to (1,1); now, can Jim cast the beam or not? It depends: If the wall is an open line segment (doesn't include the endpoints) the answer is YES, while if it's close, the answer is NO.
Do we know which case we're dealing with?
I suggest using vectors. Solve vector form of solution for pi + siqi
where pi are the position vectors and qi the translation ones
for the scalars s.
For intercept, system must be solvable and both scalars are >= 0 and <= 1.
otherwise there is none.
include
using namespace std;
int main() { int t; cin>>t; double x1,y1,x2,y2,xm,ym,x0,y0; for(int i=0;i
The solution method proposed by the editorial is non-obvious and possibly more complicated than it needs to be. A more intuitive and straightforward method (to this former vector calculus teacher) is to use parametric equations to describe the beampath and the wall. If Ri is the vector = , then problem can be rewritten " Does there exist an s and t (both between 0 and 1) so that s*R2 + (1-s)*R1 = t*Rm. From there it is straightforard linear algebra. The only special case that needs any particular care is the case where the lines are parallel, so the equations are indeterminate.
Yeah, this is equivalent to finding whether two line segments intersect (as is said at the beginning of the editorial), which is a standard problem in computational geometry.
I actually did the problem in a even more non-obvious way. I put the source at the origin and establish a non-orthogonal coordinate system with the two endpoints of the wall lying on its x and y axes (which need not be perpendicular). In the non-orthogonal system, a point (x,y) is blocked by the wall iff x>=0 and y>=0 and x+y>=1 at the same time. It is then the computer's job to do the coordinate transform. I've got to treat as a special case the situation when the x and y axes coincide.
Can someone please check my code submission? I am getting wrong answer for all except the sample test case although I feel I am close to the answer.
you can download the failing testcase and test the code in your local machine or paste it in the custom testcase window to debug your code. a video explaining the same is given here
Video link seems to not be working for me.
I just got it, small fix to a test situation in my code. Due to the fact that the video link does not seem to work, or does not work for me, if anyone needs help these are a couple of the refferences I used to solve the problem:
http://www.uiowa.edu/~examserv/mathmatters/tutorial_quiz/geometry/findingptsofintersection.html
http://www.mathopenref.com/coordintersection.html