gpt4 book ai didi

c - 有没有一种简单的方法可以在不使用大型外部库的情况下用 C 替换它?

转载 作者:太空宇宙 更新时间:2023-11-03 23:35:55 25 4
gpt4 key购买 nike

TransformationMatrices[mesh_count-1][0] = n->mTransformation.a1; 
TransformationMatrices[mesh_count-1][1] = n->mTransformation.a2;
TransformationMatrices[mesh_count-1][2] = n->mTransformation.a3;
TransformationMatrices[mesh_count-1][3] = n->mTransformation.a4;
TransformationMatrices[mesh_count-1][4] = n->mTransformation.b1;
TransformationMatrices[mesh_count-1][5] = n->mTransformation.b2;
TransformationMatrices[mesh_count-1][6] = n->mTransformation.b3;
TransformationMatrices[mesh_count-1][7] = n->mTransformation.b4;
TransformationMatrices[mesh_count-1][8] = n->mTransformation.c1;
TransformationMatrices[mesh_count-1][9] = n->mTransformation.c2;
TransformationMatrices[mesh_count-1][10] = n->mTransformation.c3;
TransformationMatrices[mesh_count-1][11] = n->mTransformation.c4;
TransformationMatrices[mesh_count-1][12] = n->mTransformation.d1;
TransformationMatrices[mesh_count-1][13] = n->mTransformation.d2;
TransformationMatrices[mesh_count-1][14] = n->mTransformation.d3;
TransformationMatrices[mesh_count-1][15] = n->mTransformation.d4;

编辑:替换为用更短的形式替换。

最佳答案

不完全确定我是否理解了这个问题,但您可以使用预处理器将其缩短很多。例如,

int WriteIndex = 0;
#define WRITE_MATRIX(prefix) \
do { \
TransformationMatrices[mesh_count-1][WriteIndex++] = n->mTransformation.prefix ## 1; \
TransformationMatrices[mesh_count-1][WriteIndex++] = n->mTransformation.prefix ## 2; \
TransformationMatrices[mesh_count-1][WriteIndex++] = n->mTransformation.prefix ## 3; \
TransformationMatrices[mesh_count-1][WriteIndex++] = n->mTransformation.prefix ## 4; \
} while(0)
WRITE_MATRIX(a);
WRITE_MATRIX(b);
WRITE_MATRIX(c);
WRITE_MATRIX(d);

我不会完全按照这种方式编写代码,但它演示了技术...

关于c - 有没有一种简单的方法可以在不使用大型外部库的情况下用 C 替换它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3601121/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com