Normal Matrix
Normals are funny. They're vec3's, since you don't want perspective on normals. And they don't actually scale quite right--a 45 degree surface with a 45 degree normal, scaled by glScalef(1,0.1,1), drops the surface down to near 0 degrees, but actually tilts the normal *up*, in the opposite direction from the surface, to near 90 degrees.
Mathematically, if between two points a and b on the surface, dot(n,b-a)==0, then after applying a matrix M to the points, you want the normal to still be perpendicular. The question is, what matrix N do you have to apply to the normal to make this happen? In other words, find N such that
dot( N * n , M * a - M * b) == 0
We can solve this by noting that dot product can be expresed as matrix multiplication--dot(x,y) = transpose(x) * y, where we treat an ordinary column-vector as a little matrix, and flip it horizontally. So
transpose(N * n) * (M*a - M*b) == 0 (as above, but write using transpose and matrix multiplication)
transpose(N * n) * M * (a-b) == 0 (collect both copies of M)
transpose(n) * transpose(N) * M * (a-b) == 0 (transpose-of-product is product-of-transposes in opposite order)
OK. This is really similar to our assumption that the original normal was perpendicular to the surface--that dot(n,b-a) == transpose(n) * (a-b) == 0. In fact, the only difference is the new matrices wedged in the middle. If we pick N to make the term in the middle the identity, then our new normal will be perpendicular to the surface too:
transpose(N) * M == I (the identity matrix)
This is the definition for matrix inverses, so the "normal matrix" N = transpose(inverse(M)).
If you look up the GLSL definition for "gl_NormalMatrix", it's defined as "the transpose of the inverse of the gl_ModelViewMatrix". Now you know why!
http://www.cs.uaf.edu/2007/spring/cs481/lecture/01_23_matrices.html
相关推荐
这个矩阵通常包括法线矩阵(Normal Matrix),它是模型视图矩阵的逆转置,用于将法线从世界空间转换到切线空间。 4. **应用转换**:使用这个矩阵,我们可以进行坐标变换:[dx, dy, dz]^T * 变换矩阵 = [dN, dE, dU]^T...
We have used many C++ optimization techniques in desiging this class to minimize/eliminate the normal programming overheads assiciated with such a class library. So, programs using this class would ...
11. Hermitian, Normal and Positive De nite Matrices 12. Kronecker Products and Singular Value Decomposition 13. Simultaneous Reduction and Vec Stacking 14. Vector and Matrix Differentiation 15. Matrix...
matrix_multiplications.cpp :一个示例程序,实现normal matrix multiplications和sparse matrix multiplications 。 建立并执行 $ cd ${pin_root}/source/tools/ $ git clone ...
4The transpose of a matrix . . . . . . . . . . . . . . . . . . . . .6 5Square matrices . . . . . . . . . . . . . . . . . . . . . . . . . . .6 6Linear forms and quadratic forms . . . . . . . . . . . . ...
1. 当矩阵A的阶数n大于或等于3时,矩阵A必须是规范矩阵(normal matrix)。 2. 当矩阵A是二阶矩阵时,它要么是规范矩阵,要么满足特定的条件,例如-c2手1,(-C2)k+1=1且trA=0。 另一方面,如果Hk(A)是单点集,则...
在图形学或者物理模拟中,法线矩阵(Normal Matrix)是用于处理物体表面法线的矩阵,特别是在光照计算中至关重要。法线矩阵通常是从模型空间到世界空间的逆 transpose,它的作用是保持法线方向在变换后的正确性。O(n...
概率密度函数 ... var matrix = require ( 'dstructs-matrix' ) , mat , out , x , i ; // Standard Normal Distribution (mu=1, sigma=1): out = pdf ( 1 ) ; // returns 0.2419707 out = pdf
分位数函数 分。 随机变量的为 对于0 <= p < 1> 0是标准偏差。... var matrix = require ( 'dstructs-matrix' ) ,mat ,out ,x ,i ;out = quantile ( 0.25 ) ;// returns ~-0.674x = [ 0 , 0.2 , 0.4 , 0.6 ,
在控制系统理论中,系统的稳定性是衡量系统在外部扰动或内部动态变化时能否保持期望行为的重要指标。Routh-Hurwitz 稳定性判据是一种数学工具,用于确定多阶线性定常系统是否稳定的经典方法。在这个Matlab程序中,...
static int Normal(int matrix[][], int N) { int s = 0; for (int j = 0; j ; j++) for (int k = 0; k ; k++) s += matrix[j][k] * matrix[j][k]; return (int)Math.sqrt(s); } ``` 矩阵的迹(Trace)则是对...
The Row and Column Spaces of a Matrix, 52 The Complexification of a Real Vector Space, 53 Exercises, 55 2 Linear Transformations, 59 Linear Transformations, 59 The Kernel and Image of a Linear ...
In this study, a MRG sample based on a polyurethane matrix was fabricated. The normal force of MRG was investigated by using an advanced commercial rheometer under rotational and oscillatory shear ...
\[ T = \begin{bmatrix} 1 & 0 & 0 & -Tx \\ 0 & 1 & 0 & -Ty \\ 0 & 0 & 1 & -Tz \\ 0 & 0 & 0 & 1 \end{bmatrix} \] 接下来是旋转操作,这涉及到绕X、Y、Z轴的旋转,通常使用欧拉角(yaw, pitch, roll)来描述。...
本篇文章将详细讨论“Shrinkage covariance matrix estimators”,特别是陈等在201年发表于《IEEE Transactions on Signal Processing》上的“Minimum Mean Square Error (MMSE) 协方差估计的收缩算法”。...
cv::normal(normal_matrix, Scalar(0), Scalar(1)); // 生成标准正态分布 ``` 在Visual Studio环境下,你可以利用OpenCV的这些功能来创建交互式的可视化工具,展示生成的矩阵。例如,可以使用`cv::imshow()`函数...
std::normal_distribution<double> distribution(mean, stddev); return distribution(generator); } ``` 3. **卡尔曼滤波算法实现**:基于上述准备,可以实现卡尔曼滤波的核心部分。 ```cpp void kalman...
This approach resolves the artifact of a discontinuous normal derivative typically found in the R-matrix method. In addition, we show that, by excluding the aforementioned inhomogeneou
elementary alternating tensors, elementary matrix corresponding, neighborhood that intersects, overlap positively, single coordinate patch, rectifiable subset, rectifiable set, extended integral, ...
BCLS is a software package for solving bound-constrained least-...The normal equations are never formed. The user may provide perconditioners in order to accelerate the solution of the subproblems.