简体   繁体   English

分析面法线

[英]normal for analytical surface

I'm calculating surface normal for my analytical surface. 我正在为我的分析表面计算表面法线。 Some parts of normal i'm getting are correct but not all. 我得到的正常的某些部分是正确的,但不是全部。 Code is : 代码是:

SurfaceVertices3f[pos] = i;
SurfaceVertices3f[pos+1] = j;
SurfaceVertices3f[pos+2] = (cos(i)*sin(j));

/*a and b hold the poutput of partial differentiation of vertices from above three lines.a is wrt i and b is wrt j */           
a[0]=1;
a[1]=0;
a[2]=-sin(i)*sin(j);

b[0]=0;
b[1]=1;
b[2]=cos(i)*cos(j);

normal_var=Vec3Df::crossProduct( a, b);
normal_var.normalize();

My output looks like this, right image is mine and left one i'm using as refrence . 我的输出看起来像这样,右图是我的,左图是我正在用作参考。 http://tinypic.com/view.php?pic=73l9co&s=5 http://tinypic.com/view.php?pic=73l9co&s=5

Could anyone tell me what mistake i'm doing? 谁能告诉我我在做什么错误?

Your normal calculation is correct. 您的正常计算是正确的。 The reference image has just a different way to map normals to colors. 参考图像只是一种将法线映射到颜色的方法。

If you have a look at the green ground color, you will see that the color's norm is not 1. But normals should have a norm of 1. If we assume another common mapping from normal to color like this one: 如果您查看绿色底色,您会发现该颜色的范数不是1。但是法线的范数应该为1。如果我们假设从法线到颜色的另一种通用映射是这样的:

color.rgb = normal.xyz / 2 + 0.5

We see that this is no unit vector either. 我们看到这也不是单位向量。 So either they used yet a different mapping or they just don't have unit length normals. 因此,他们要么使用了不同的映射,要么就没有单位长度法线。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM