您的位置:首页 > 其它

快速求出三角形其它两个点的索引

2008-08-01 01:20 162 查看
inline void tri_get_other_vert_index( int i,int& a,int& b )
{
static int other_index_1[3] = {1,0,0};
static int other_index_2[3] = {2,2,1};

a = other_index_1[i];
b = other_index_2[i];

}

通常用在循环处理三个顶点时,每次都需要得到另外两个顶点时;也可用于得到快速得到另外两条边.
如果用条件判断,那么每个循环至少需要判断2次,如下所示:

inline void tri_get_other_vert_index( int i,int& a,int& b )
{

if( i == 0 )
a = 1,b=2;
else if( i == 1)
a = 0,b=2;
else
a = 0,b=2;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: