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经常在编译时产生异常直接关闭,还让我给微软提交错误报告,真不知道是不是系统有问题!不管这些了,今天的教训是在以后写代码的路上,要仔细点!多写写把, 自己看的写的实在是太少了!


  • 相关阅读:
    Libgdx之Music Sound 音效
    [Android]Activity的生命周期
    Android开发中无处不在的设计模式——动态代理模式
    Wireshark数据抓包分析——网络协议篇
    iOS-一个弹出菜单动画视图开源项目分享
    给Java开发人员的Play Framework(2.4)介绍 Part1:Play的优缺点以及适用场景
    mybatis自己学习的一些总结
    Cocos2d-x 源代码分析 : Scheduler(定时器) 源代码分析
    exe4j打包java应用程序
    删除sql server用户时报15138错误
  • 原文地址:https://www.cnblogs.com/duke/p/2022653.html
Copyright © 2011-2022 走看看