如何获取3D矢量的剩余轴知道其他两个
How to get the remaining axis of a 3d vector knowing the other two?
我需要获得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;
}
}
所以我可以这样做:
v[get_remain_axis(a, b)]
但是我需要在此操作中效率,如果可能的话,如果它是原子。
如何更有效地执行此功能?
至少在我阅读内容时,您的轴0
,1
和2
。输入是其中两个,您想返回第三个。
假设是这样,这三个数字最多需要3个,因此您可以做:return 3 - (a + b);
相关文章:
- 在执行其他功能的同时播放动画(LED矩阵和Arduino/ESP8266)
- 将数组作为参数传递给函数安全吗?作为第三方职能部门,可以探索他们想要的之外的其他元素
- 有没有什么方法可以使用一个函数中定义的常量变量,也可以由c++中同一程序中的其他函数使用
- 如何用参数值调用函数(仅在运行时已知)
- GL_SHADERSTORAGE_BUFFER位置是否与其他着色器位置冲突
- 为什么我不能在 C++ 中的特定函数重载中调用同一函数的任何其他重载?
- 在其他文件中创建类时在 c++ 项目中不起作用
- 类与私有变量的其他类之间的线程安全性
- 将--whole archive链接器选项与CMake和具有其他库依赖项的库一起使用
- GlobalAlloc而不是其他分配方法
- C++从其他 constexpr 创建 lambda 不能按顺序执行 Constexpr
- 断言中的Fold表达式在某些计算机上编译,但在其他计算机上不编译
- Visual Studio(或任何其他工具)能否将地址解释为调用堆栈(boost上下文)的开头
- QwtPlot具有相等的轴和自动缩放
- 结构和双指针隐藏在其他结构中,多层混淆
- UE4在OnComponentBeginOverlap上铸造其他actor
- 当我在其中一个线程执行中(在activemq-cpp中)捕获到特定值时,我如何终止/停止所有其他线程
- 如何获取3D矢量的剩余轴知道其他两个
- 如何根据其ARITY(或编译时已知的其他信息)以不同的方式调用函数对象
- 以其他矢量为轴旋转矢量