Back to General discussions forum
could you tell me please how angle between the direction to the given hobbit and the direction in which the Rider looks is calculated please
At first you have to calculate a vector from Rider to hobbit. Then convert this vector from rectangular coordinates to polar coordinates. Use atan2 library function for convenience. Then subtract angle of vector from angle of rider - it gives what you ask for.
thanks, for your help
for the data : 5 15 73 1.9 43 29 1.2 18 79 -0.2 89 28 0.5 80 54 -2.4
i got : 48 34 18 0 0 0
the expected answer is 50 34 17 0 0 0 104 > 100
so i think my answer is better but considered as wrong
is the checker right??
I run my solution on your data and set rounding to 0.1. It gives me 49.8 33.7 16.5 0.0 0.0 0.0 as result. So I think checker is ok.
thanks, it worked now
I have to say that I could not figure out what was wrong with my solution. I assumed the 100 x 100 grid was X = -50 to 50 and y = -50 to 50. So much time wasted checking if the points were inside the vision shape or outside the shape etc. If only I had realized sooner that the grid numbers are all positive. X = 0 through 100 and y = 0 through 100.
Mithrandir, Hi!
That's wonderful that problem about Frodo (probably the only we have on LotR
theme) is solved by colleague with
such a suitable name :)
Thanks a lot for your hint. I just vaguely remember the task, but judging from the code you are quite right - and so I added clarification on field corner's coordinates, to prevent confusing more people!
Hi Rodion, Thanks for adding the clarification to the problem statement. The good news is I was forced to go much deeper into the analysis of the problem because I could not figure out why I was not getting the right answer. I was outputting points to CSV and graphing in Excel and when that didn't work I was using the CSV data to draw rider vision shapes in CAD to analyze the area and the overlapping areas because I couuldn't find any more errors in my logic or my code. Then the idea about the grid definition hit me and I was able to solve but I think I learned a lot more by not getting to the solution right away.
Thanks also creating and running the website. I really like it.
-Mithrandir