请问如何在MarchingCube算法getdepth功能的工作? [英] how does getdepth function work in MarchingCube algorithm?

查看:128
本文介绍了请问如何在MarchingCube算法getdepth功能的工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解移动立方体算法,所以我想我已经知道如何三角形的形成,以及如何法线计算每个网格研究。我可以看到有一个链表的一种结构,每个格链接到另一个。但是,当我遇到GetDepth(T [M]),后者每一个三角形(每个网格的这些三角形)(T [0],...,..)单独,它返回节​​点的深度。

I am trying to understand Marching Cube Algorithm, so for I think I have understood how triangles are formed and how normals are calculated in each grid. I can see there is a linked list kind of structure that links each grid to another. But when I come across GetDepth(t[m]) which passes each triangles (those triangles of each grid) (t[0],..,..)individually, it returns depth of the node.

函数,

float GetDepth(TRIANGLE t) {

    float z;
    z = t.p[0].z;
    z = t.p[1].z > z? t.p[1].z: z;
    z = t.p[2].z > z? t.p[2].z: z;
    return z;
}

它看起来像它试图找到最大Z(这是真的)。 我可以看到,它比较>,然后我失去了它。 任何一个可以请解释这里发生了什么。

It looks like its trying to find max z(is it true). I can see that it compares " > " and then I lost it. Can any one please explain what is happening here.

推荐答案

这似乎是你不熟悉?作为三元运算符。 您发布的code是等同于以下内容:

It would seem that you are unfamiliar with ? as a ternary operator. The code you posted is equivalent to the following:

float GetDepth(TRIANGLE t) {

float z;
z = t.p[0].z;
if (t.p[1].z > z) {z = t.p[1].z;} else {z = z;}
if (t.p[2].z > z) {z = t.p[2].z;} else {z = z;}
return z;
}

是的,这确实发现在p数组中的最大的Z-。

And yes, this does find the maximum z in the p array.

这篇关于请问如何在MarchingCube算法getdepth功能的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆