随笔 - 9, 文章 - 0, 评论 - 0, 引用 - 0
数据加载中……

三角形切线推导

void calcTangent(VECTOR3D& p0,VECTOR3D& p1,VECTOR3D& p2, VECTOR2D& t0,VECTOR2D& t1,VECTOR2D& t2, VECTOR3D& tangent) { VECTOR3D edge1 = p1 - p0; VECTOR3D edge2 = p2 - p0; float du1 = t1.x - t0.x; float du2 = t2.x - t0.x; float dv1 = t1.y - t0.y; float dv2 = t2.y - t0.y; float f = 1.0f / (du1 * dv2 - du2 * dv1); tangent.x = f * (dv2 * edge1.x - dv1 * edge2.x); tangent.y = f * (dv2 * edge1.y - dv1 * edge2.y); tangent.z = f * (dv2 * edge1.z - dv1 * edge2.z); tangent.Normalize(); }

posted on 2016-01-15 11:22 niomaa 阅读(256) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理