小编Man*_*Wii的帖子

有了tan(x),我怎么能得到tan(x/2)?在C.

我知道我可以这样做:

//With A = tax(x);
return tan(arctan(A)/2);
Run Code Online (Sandbox Code Playgroud)

但我想要更高效的东西.

c math

1
推荐指数
1
解决办法
62
查看次数

如何知道另外两个的3d矢量的剩余轴?

我需要得到3d矢量"v [3]"的剩余值

我有一个函数返回剩余的轴,其他两个作为参数:

static get_remain_axis(const short a, const short b) {
    if (a == 0) {
        if (b == 1)
            return 2;
        else
            return 1;
    }
    else if (a == 1) {
        if (b == 0)
            return 2;
        else
            return 0;
    }
    else {
        if (b == 0)
            return 1;
        else
            return 0;
    }
}
Run Code Online (Sandbox Code Playgroud)

所以我可以这样做:

v[get_remain_axis(a, b)]
Run Code Online (Sandbox Code Playgroud)

但是我需要在这个操作中有效率,如果可能的话,如果它是原子的,那就太好了.

如何更有效地完成此功能?

c c++ math

0
推荐指数
1
解决办法
41
查看次数

标签 统计

c ×2

math ×2

c++ ×1