Retired
Calculate the bearing angle angle between two points (retired)
42daymos
Loading description...
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Decent kata :
But
As always, might generate issues with rounding in rare cases.
There are issues in the answers for rounding. For eg: -126.86989764584402 Expected: -126, instead got: -127
There is a major issue with the kata, because the description is vague about what angle is desired.
You need to define exactly what you mean by 'angle between 2 position vectors'. Traditionally, angles are measured between rays that share a vertex, so I thought that you wanted the angle between the rays from [0,0] projected through the two points. This is also the normal meaning of the angle between two position vectors; there is even a nifty formula based on the dot product. Google "dot product angle between two vectors". But nope, that's not what's being tested here.
By trial and error, I discovered that rather than the usual angle between two position vectors, you wanted the angle between the ray from [x1,y1] projected through [x2,y2] and the ray pointing from [x1,y1] to the right in the direction of the positive x-axis. In other words the direction (or heading) when moving from point 1 to point 2, relative to the positive x-axis.
This is by no means clear from the description of the kata. Adding a picture would be helpful to clear up the confusion.
You need a bigger upvote.
Description updated.
The answers in the tests are wrong!
The mathematics in this Kata seems wrong to me, unless I have remembered the equation for finding the angle between two vectors wrong. Please double check your maths.
If you believe the maths to be correct, please cite the source you are using.
The description was off.
Rounding should be better explained.
.
.
Either the test cases are wrong or the problem needs to be rewritten.
Consider the second test case: (-1,0) and (5,-2) the angle between these is show here. https://imgur.com/ZrdkR0q. As you can see it's much more than -18.
First test case: (-1,0) and (5,0). These position vectors are in direct opposite positions. Should be 180 degrees, not zero.
.
The description says nothing about rounding.
I added that to the description, and a better explanation of what angle to calculate.
Up / down / to zero / to infinity?
down
That is not really down, as inferred from test cases. By the word down one rounds 4.5 as 4, but -4.5 as -5. That is not the behaviour of your test cases:
This kata has only one caveat: it does not follow the good old definitions when people do math, but the very same words are used. For a math kata, with due respect, this caveat is fatal.
I don't think there's such a thing as an angle between points, is there?
Well, you are right, I could express it better in the description. Points are used to define a position vector. And the angle is between the position vectors.
Description says :
... but degrees are expected
doh! thanks, I changed the description.
:)