在3D建模的世界里,计算公式就像是工匠的锤子和凿子,是构建虚拟世界的基石。无论是初学者还是经验丰富的设计师,掌握必要的3D计算公式都是不可或缺的。下面,我们就来一图掌握全部3D计算公式大全,助你在建模的道路上更加得心应手。
1. 坐标系与坐标变换
1.1 世界坐标系(World Coordinate System)
- ( x = x_0 + dx )
- ( y = y_0 + dy )
- ( z = z_0 + dz )
1.2 视觉坐标系(View Coordinate System)
- ( x’ = x \cdot cos(\theta) - y \cdot sin(\theta) )
- ( y’ = x \cdot sin(\theta) + y \cdot cos(\theta) )
- ( z’ = z )
1.3 屏幕坐标系(Screen Coordinate System)
- ( x’ = \frac{2x}{w} - 1 )
- ( y’ = \frac{2y}{h} - 1 )
- ( z’ = \frac{2z}{d} - 1 )
2. 3D几何计算
2.1 向量运算
- 向量加法:( \vec{A} + \vec{B} = (A_x + B_x, A_y + B_y, A_z + B_z) )
- 向量减法:( \vec{A} - \vec{B} = (A_x - B_x, A_y - B_y, A_z - B_z) )
- 向量点乘:( \vec{A} \cdot \vec{B} = A_x \cdot B_x + A_y \cdot B_y + A_z \cdot B_z )
- 向量叉乘:( \vec{A} \times \vec{B} = (A_y \cdot B_z - A_z \cdot B_y, A_z \cdot B_x - A_x \cdot B_z, A_x \cdot B_y - A_y \cdot B_x) )
2.2 点到线段距离
- ( d = \frac{|(\vec{B} - \vec{A}) \times (\vec{C} - \vec{A})|}{|\vec{B} - \vec{A}|} )
2.3 线段相交
- ( t_1 = \frac{(B_x - A_x) \cdot (C_y - A_y) - (B_y - A_y) \cdot (C_x - A_x)}{(B_x - A_x) \cdot (D_y - A_y) - (B_y - A_y) \cdot (D_x - A_x)} )
- ( t_2 = \frac{(C_x - A_x) \cdot (D_y - A_y) - (C_y - A_y) \cdot (D_x - A_x)}{(B_x - A_x) \cdot (D_y - A_y) - (B_y - A_y) \cdot (D_x - A_x)} )
3. 3D变换
3.1 旋转
- 2D旋转:( x’ = x \cdot cos(\theta) - y \cdot sin(\theta) )
- ( y’ = x \cdot sin(\theta) + y \cdot cos(\theta) )
- 3D旋转(绕X轴):( x’ = x )
- ( y’ = y \cdot cos(\phi) - z \cdot sin(\phi) )
- ( z’ = y \cdot sin(\phi) + z \cdot cos(\phi) )
3.2 平移
- ( x’ = x + dx )
- ( y’ = y + dy )
- ( z’ = z + dz )
3.3 缩放
- ( x’ = x \cdot scale_x )
- ( y’ = y \cdot scale_y )
- ( z’ = z \cdot scale_z )
4. 光照计算
4.1 法线计算
- ( \vec{n} = \frac{\vec{A} \times \vec{B}}{|\vec{A} \times \vec{B}|} )
4.2 镜面反射
- ( \vec{R} = 2 \cdot (\vec{N} \cdot \vec{L}) \cdot \vec{N} - \vec{L} )
4.3 漫反射
- ( I_d = k_d \cdot I_l \cdot |\vec{L} \cdot \vec{N}| )
5. 总结
以上就是我们一图掌握的全部3D计算公式大全。当然,这只是冰山一角,3D建模的世界博大精深,需要我们不断学习和实践。希望这些公式能够帮助你更好地理解和掌握3D建模的技巧,创造出更多精彩的作品。
