zoukankan
html css js c++ java
求切线和次法线
//
let P = v1 - v0
D3DXVECTOR3 P
=
v1.pos
-
v0.pos;
//
let Q = v2 - v0
D3DXVECTOR3 Q
=
v2.pos
-
v0.pos;
float
s1
=
v1.s
-
v0.s;
float
t1
=
v1.t
-
v0.t;
float
s2
=
v2.s
-
v0.s;
float
t2
=
v2.t
-
v0.t;
//
we need to solve the equation
//
P = s1*T + t1*B
//
Q = s2*T + t2*B
//
for T and B
//
this is a linear system with six unknowns and six equatinos, for TxTyTz BxByBz
//
[px,py,pz] = [s1,t1] * [Tx,Ty,Tz]
//
qx,qy,qz s2,t2 Bx,By,Bz
//
multiplying both sides by the inverse of the s,t matrix gives
//
[Tx,Ty,Tz] = 1/(s1t2-s2t1) * [t2,-t1] * [px,py,pz]
//
Bx,By,Bz -s2,s1 qx,qy,qz
//
solve this for the unormalized T and B to get from tangent to object space
float
tmp
=
0.0f
;
if
(fabsf(s1
*
t2
-
s2
*
t1)
<=
0.0001f
)
{
tmp
=
1.0f
;
}
else
{
tmp
=
1.0f
/
(s1
*
t2
-
s2
*
t1 );
}
tangent.x
=
(t2
*
P.x
-
t1
*
Q.x);
tangent.y
=
(t2
*
P.y
-
t1
*
Q.y);
tangent.z
=
(t2
*
P.z
-
t1
*
Q.z);
tangent
=
tmp
*
tangent;
binormal.x
=
(s1
*
Q.x
-
s2
*
P.x);
binormal.y
=
(s1
*
Q.y
-
s2
*
P.y);
binormal.z
=
(s1
*
Q.z
-
s2
*
P.z);
binormal
=
tmp
*
binormal;
查看全文
相关阅读:
jQuery弹出层插件大全:
JavaScript数组去重的几种方法
sql去除重复列(行)
VS无法启动调试
.将DayOfWeek转换成中文的几种方式
关于 uniqueidentifier
链接服务器
我的目标:系统架构师
异常(1)
Visual C++开发工具与调试技巧整理
原文地址:https://www.cnblogs.com/ylwn817/p/2718337.html
最新文章
要不要吃掉它
对技术的态度
本地搭建wordpress固定链接404错误解决办法
How Does a Hold on Credit Cards Work?
Linux Desktop Entry 文件深入解析
项目使用.NET+Oracle遇到的问题
C#的String.Split 方法
c#下oracle分页方法
vml基础
oracle级联删除
热门文章
Oracle字符串截取
Oracle的to_date
jquery checkbox全选~!
过滤不安全的HTML代码
jquery实现布局高宽自适应
解决JS和jQuery冲突思路及解决办法
出现“从客户端xxx中检测到有潜在危险的 Request.Form 值“的解决方法
25个JQuery提示插件
用ckeditor分页符结合正则表达式给文章分页
.net下的生成静态页面并分页
Copyright © 2011-2022 走看看