9 Commits

Author SHA1 Message Date
David Briscoe
39aee9a421 Fix angle_to to produce signed angle
angle_to was producing the angle from +x to the difference between a,b
which is unexpected. Instead, it should produce the smallest absolute
angle between the two vectors and be signed to indicate the direction of
rotation.

By using the old angle_to implementation and modifying equal() to print
out the failures, you can see the numbers that it was producing before
didn't make much sense:

    right:angle_to(down) = 45.0
    right:angle_to(left) = 0.0
    right:angle_to(up)   = -45.0
    down:angle_to(right) = -135.0
    down:angle_to(left)  = -45.0
    down:angle_to(up)    = -90.0
    left:angle_to(down)  = 135.0
    left:angle_to(up)    = -135.0
    up:angle_to(right)   = 135.0
    up:angle_to(down)    = 90.0
    up:angle_to(left)    = 45.0

Now it produces numbers you'd expect:

    right:angle_to(down) = -90.0
    right:angle_to(left) = 180.0
    right:angle_to(up)   = 90.0
    down:angle_to(right) = 90.0
    down:angle_to(left)  = -90.0
    down:angle_to(up)    = 180.0
    left:angle_to(down)  = 90.0
    left:angle_to(up)    = -90.0
    up:angle_to(right)   = -90.0
    up:angle_to(down)    = 180.0
    up:angle_to(left)    = 90.0

See also https://stackoverflow.com/questions/21483999/using-atan2-to-find-angle-between-two-vectors

Also added tests for angle_between.
2021-06-15 11:56:04 -07:00
Colby Klein
0ff68c69fd fix lerp for vec3, update tests for broken lerp case 2017-05-19 09:49:07 -07:00
Colby Klein
65e3676af5 swap lerp arg order, fix tests 2017-03-29 07:42:40 -07:00
Colby Klein
0b0bea16ef add some lerp/decay tests 2017-03-29 05:32:31 -07:00
karai17
52814eed9f Added a few more specs, no new tests though 2016-07-25 02:07:24 -03:00
Matthew Blanchard
c5d02e0683 Updated vec3 doc comments. Brought vec2 in line with vec3. Doc commented vec2. 2015-12-25 18:35:03 -05:00
Colby Klein
e6b9c84a6c Add utils.deadzone and threshold + tests 2015-08-15 01:19:44 -07:00
Colby Klein
b6c8164935 Add precision argument to utils.round 2015-04-25 06:29:20 -07:00
Colby Klein
4cecab73c2 Add initial vec3 and utils specs 2015-04-25 05:49:36 -07:00