zoukankan      html  css  js  c++  java
  • atan与atan2的区别

         形状上下文的代码已经写成好久了,今天猛然发现这个ShapeContext直方图对任何形状都是分布在一、四区间的。这才意识到写错了。这个问题浪费了我接近半天的时间,直到单步才知道atan2的返回值有问题。原来atan2是不用你费心去判断区间的,其区别如下。还有个错误,是强制转换为整形时括号的位置不对!

    atan, atan2

    Calculates the arctangent of x (atan) or the arctangent of y/x (atan2).

    double atan( double x );

    double atan2( double y, double x );

    Routine 

    Required Header 

    Compatibility

    atan

    <math.h>

    ANSI, Win 95, Win NT

    atan2

    <math.h>

    ANSI, Win 95, Win NT

     

    For additional compatibility information, see Compatibility in the Introduction.

    Libraries

    LIBC.LIB

    Single thread static library, retail version

    LIBCMT.LIB

    Multithread static library, retail version

    MSVCRT.LIB

    Import library for MSVCRT.DLL, retail version

     

    Return Value

    atan returns the arctangent of x. atan2 returns the arctangent of y/x. If x is 0, atanreturns 0. If both parameters of atan2 are 0, the function returns 0. You can modify error handling by using the _matherr routine. atan returns a value in the range –π/2 to π/2 radians; atan2 returns a value in the range –π to π radians, using the signs of both parameters to determine the quadrant of the return value.

    Parameters

    xy

    Any numbers

    Remarks

    The atan function calculates the arctangent of xatan2 calculates the arctangent ofy/xatan2 is well defined for every point other than the origin, even if x equals 0 and ydoes not equal 0.

        事实上这是个很简单的函数运用问题,但当时的疏忽知道几个月后才被发现!真的很惭愧,总想着去写个涵括多种方法的目标跟踪程序,但到现在我的程序都只能跑一段,不规则的出现堆栈报错,却一直不知道怎么去差错。另外,我的VS2003经常在编译时产生异常直接关闭,还让我给微软提交错误报告,真不知道是不是系统有问题!不管这些了,今天的教训是在以后写代码的路上,要仔细点!多写写把, 自己看的写的实在是太少了!


  • 相关阅读:
    20165334 四则运算阶段性总结(第二周)
    20165334 《java程序设计》第8周学习总结
    20165334四则运算阶段性总结(第一周)
    20165334 《java程序设计》第7周学习总结
    20165334实验二 面向对象程序设计
    20165334《java程序设计》第六周学习总结
    2017-2018-2 20165228 实验四《Android程序设计》实验报告
    第十周课堂测试补做
    2017-2018-2 20165228 实验三《敏捷开发与XP实践》实验报告
    20165228 2017-2018-2 《Java程序设计》第9周学习总结
  • 原文地址:https://www.cnblogs.com/duke/p/2022653.html
Copyright © 2011-2022 走看看