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;
查看全文
相关阅读:
构建前端第8篇之---Webstom搭建ES6运行环境
方法重写
继承的成员变量的访问特定
继承的理解
总结与新的开始
python 小案例demo07
python 小案例demo06
python 小案例demo05
python 小案例demo05 升级版石头剪刀布
python 小案例demo04
原文地址:https://www.cnblogs.com/ylwn817/p/2718337.html
最新文章
【LabVIEW】串口通讯
【LabVIEW】树形控件
【LabVIEW】连接sql server数据库
【LabVIEW】当前VI路径和应用程序目录的区别
【LabVIEW】数组与簇的使用
【LabVIEW】执行系统(多线程)
【LabVIEW】波形图表(Chart)、波形图(Graph)
【WinForm】Dev BarStaticItem、Label问题汇总
2440 U-BOOT 的理解
2440的驱动的研究
热门文章
触摸屏的使用笔记
2440的ADC,触摸屏的使用
构建后端第3篇之---springb @Alias注解使用
构建后端第2篇之---springb @ComponentScan注解使用
构建后端第1篇之---springcloud项目依赖分析
构建前端第12篇之---在Vue中对组件,变量,函数的全局引入
构建前端第11篇之---es6中的import 和outport的使用
构建前端第10篇之---Function.prototype.call()
构建前端第9篇之(下)---vue3.0将template转化为render的过程
构建前端第9篇之(上)---Vue组件引入,使用
Copyright © 2011-2022 走看看