Skip to content

math.Atan2 parameters are confusing #220

@gopherbot

Description

@gopherbot

by Scott.Kimble:

Typically, atan2 is written in the form atan2(y, x). In this case, there is
a natural association between parameters and coordinates--the first
paramter 'y' is associated with the 'y' coordinate and the second parameter
'x' is associated with the 'x' coordinate.

'Go' has inverted the parameter names by defining atan2(x, y) and broken
the natural association between parameters and coordinates--the first
paramter 'x' is associated with the 'y' coordinated and the second
parameter 'y' is associated with the 'x' coordinate.

For example, when x=0.0 and y=1.0
    Atan2(x, y) => Atan2(0.0, 1.0) == 0 (which is not what we want)
To get the correct result, we have to ignore the parameter names.
    Atan2(x, y) => Atan2(y, x) => Atan2(1.0, 0.0) == Pi/2 (what we want)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions