首页 > 编程知识 正文

投影向量公式证明,向量和的投影等于投影的和怎么证明

时间:2023-05-06 11:32:13 阅读:275082 作者:1894

https://stackoverflow.com/questions/52339320/unity-shader-hlsl-equivalent-of-vector3-projectonplane
a 在 b 上的投影

感觉向量还是这样写好看


mathmatica

Dot[{1,0} , {-1,0}] // 点乘 是一个数{1,0} x {-1,0}// 叉乘 是一个向量 // If your plane normal vector is normalized:inline float3 projectOnPlane( float3 vec, float3 normal ){ return vec - normal * dot( vec, normal );}// If it's not:inline float3 projectOnPlane( float3 vec, float3 normal ){ return vec - normal * ( dot( vec, normal ) / dot( normal, normal ) );}// Same formula, depending on GPU model & driver version can be either faster or slower:inline float3 projectOnPlane( float3 v, float3 n ){ float3 r; r.x = n.y * n.y * v.x + n.z * n.z * v.x - n.x * n.y * v.y - n.x * n.z * v.z; r.y = n.x * n.x * v.y - n.x * n.y * v.x - n.y * n.z * v.z + n.z * n.z * v.y; r.z = n.x * n.x * v.z - n.x * n.z * v.x + n.y * n.y * v.z - n.y * n.z * v.y; return r / dot(n, n);}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。