Skip to content

Replace a few occurrences of atan(Y/X) with atan2(Y, X) #59

@WarrenWeckesser

Description

@WarrenWeckesser

A potential bit of code maintenance:

I noticed a few occurrences of atan(Y/X) in the xsf code. Generally these can be written atan2(Y, X), which avoid a potential division by 0 and gives results from (-pi, pi) instead of (-pi/2, pi/2). Here's what a search with a regex finds:

$ rg "atan\([^)]*/.*\)"
specfun/specfun.h
706:                        phi = atan(y / x);
785:        th = atan(yy / x0);
798:                gi1 += atan(yy / (xx + j));
805:            th1 = atan(yy / xx);
809:            th2 = atan(si / sr);

amos/amos.h
3363:            t1 = fabs(atan(yy / xx));
4821:                    ang = atan(zthi / zthr);

It might be worthwhile checking if any of those can be replaced by atan2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions