向量点乘(内积)r = (a,b,c)*(x,y,z)=ax+by+cz,是一个标量

这几天,在看Unity3D,很有意思,其中看到,第一人称控制器,就想看到里面的一些控制脚本是如何实现,才发现,学到的好多数据知识已经还给老师了,还好,走遍大江南北,跟着的书不多,唯一的二本高数没丢.

然后参考网上各个简洁明了的讲洁.

主要有http://my.csdn.net/cppyin 的从零实现3D图像引擎.

用此文只是用来记录一些向量,矩阵等的操作.没别的实际意义.会与我的学习来更新此文章.

1.求矩阵的逆矩阵。

View Code
2.求二线段有没交点。交点的位置。这个看从零系列文章的时候,开始没想通怎么到作者是如何来求t1,t2那一步的,然后用F#自己来推导,原来如此。

View Code
val x1 : XMath.XSegment2
val x2 : XMath.XSegment2
val w : float = 0.5
val r : XMath.XPoint2
val q : float = -0.5
val e : XMath.XPoint2
val it : float * float * float * float = (5.0, 3.0, 5.0, 3.0)

3.向量点乘(内积)r = (a,b,c)(x,y,z)=ax+by+cz,是一个标量,不具有方向了。有如下关系,cos@=r/(|a,b,c||x,y,z|).而cos@=一边的投影长度/另一边。所以用来求二个向量之间投影向量与对应的法向量。

向量叉乘(叉积)r=(a,b,c)(x,y,z)=(bz-yc,-az+xc,ay-bx).是一个向量,有如下关系,sin@=|r|/(|a,b,c||x,y,z|).其中r与向量(a,b,c),(x,y,z)互相垂直。

二个向量的叉积结合相应坐标系来看,就是各项的代数余子式。

4.OpenGL里的摄像机与透视矩阵.

用F#实现OpenTK上的一个小例子。相关代码是画一个立方体,然后不断旋转。

用的OpenGL,对应的是列向量,右手坐标系。

相关个人理解,不论是OpenGL或是D3D,人站在地面上,在3维里,XZ面是表示地面,Z用来表示远近(人眼看的远近),Y用来表示高度。我们眼中看到的平面应该平行于XY面。人相当于是地面(XZ面)的法向量。

而透视投影用在实际当中来说,人眼选择一个近处1米到远处10米的所有物体,在这当中所有物体会影视到我们眼球表面。透视投影相当于就是计算视线内所有物体到眼球表面上的位
print("--------------------------------");
print("类似throw exception(该方法抛异常之后,整个代码文件不往下走.)");
function addTestThrowException(a)
assert(type(a) == "number", "a 不是一个数字") --异常之后,后面的代码不执行
return a*a;
end
print(addTestThrowException(5));
--[[
输出结果:
类似throw exception
25
]]
--print(addTestThrowException("ab"));
--[[
解开上面的注释,输出结果:
lua: Lua-调试.lua:10: a 不是一个数字
stack traceback:
[C]: in function 'assert'
Lua-调试.lua:10: in function 'addTestThrowException'
Lua-调试.lua:19: in main chunk
[C]: ?
]]

print("--------------------------------");
print("pcall:类似try-catch但不提供 调试信息");
print("pcall(addTestThrowException,5)=",pcall(addTestThrowException,5));
print("pcall(addTestThrowException,"a")=",pcall(addTestThrowException,"a"));

print("--------------------------------");
print("xpcall类似try-catch但且提供调试信息 ");
local function addTestThrowException2(a)
print(a);
return a*a;
end

function processException(err)
--debug.debug();
--print(debug.debug());
--print("ERROR:",err);
--print(debug.getinfo(1))
debug.traceback();
return false;
end
print(addTestThrowException2(5));
xpcall(addTestThrowException2,processException,5);
https://m.xiami.com/collect/1243215486
https://emumo.xiami.com/collect/1243215486
https://m.xiami.com/collect/1243218373
https://m.xiami.com/collect/1243207764
https://emumo.xiami.com/collect/1243213566
https://m.xiami.com/collect/1243213566
https://emumo.xiami.com/collect/1243218373
https://m.xiami.com/collect/1243205822
https://emumo.xiami.com/collect/1243205822
https://m.xiami.com/collect/1243205821
https://emumo.xiami.com/collect/1243205821
https://emumo.xiami.com/collect/1243215485
https://m.xiami.com/collect/1243215485
https://m.xiami.com/collect/1243214532
https://emumo.xiami.com/collect/1243214532
https://m.xiami.com/collect/1243206797
https://emumo.xiami.com/collect/1243206797
https://m.xiami.com/collect/1243213564
https://emumo.xiami.com/collect/1243213564
https://m.xiami.com/collect/1243218372
https://emumo.xiami.com/collect/1243218372
https://m.xiami.com/collect/1243215482
https://emumo.xiami.com/collect/1243215482
https://m.xiami.com/collect/1243213562
https://emumo.xiami.com/collect/1243213562
https://m.xiami.com/collect/1243210643
https://emumo.xiami.com/collect/1243210643
https://m.xiami.com/collect/1243210642
https://emumo.xiami.com/collect/1243210642
https://m.xiami.com/collect/1243219341
https://m.xiami.com/collect/1243208754
https://emumo.xiami.com/collect/1243208754
https://m.xiami.com/collect/1243201779
https://emumo.xiami.com/collect/1243201779
https://m.xiami.com/collect/1243211572
https://emumo.xiami.com/collect/1243211572
https://m.xiami.com/collect/1243209743
https://emumo.xiami.com/collect/1243209743
https://m.xiami.com/collect/1243213557
https://emumo.xiami.com/collect/1243213557
https://emumo.xiami.com/collect/1243207758
https://m.xiami.com/collect/1243207758
https://m.xiami.com/collect/1243218360
https://emumo.xiami.com/collect/1243218360
https://m.xiami.com/collect/1243210628
https://emumo.xiami.com/collect/1243210628
https://m.xiami.com/collect/1243217403
https://emumo.xiami.com/collect/1243217403
https://m.xiami.com/collect/1243216423
https://emumo.xiami.com/collect/1243216423
https://m.xiami.com/collect/1243206779
https://emumo.xiami.com/collect/1243206779
https://m.xiami.com/collect/1243206778
https://emumo.xiami.com/collect/1243206778
https://m.xiami.com/collect/1243218357
https://emumo.xiami.com/collect/1243218357
https://m.xiami.com/collect/1243216414
https://emumo.xiami.com/collect/1243216414
https://emumo.xiami.com/collect/1243208729
https://m.xiami.com/collect/1243218347
https://emumo.xiami.com/collect/1243218347
https://m.xiami.com/collect/1243208729
https://emumo.xiami.com/collect/1243217389
https://m.xiami.com/collect/1243217389
https://emumo.xiami.com/collect/1243217387
https://m.xiami.com/collect/1243214504
https://m.xiami.com/collect/1243213536
https://emumo.xiami.com/collect/1243213536
https://m.xiami.com/collect/1243207747
https://emumo.xiami.com/collect/1243207747
https://emumo.xiami.com/collect/1243211545
https://m.xiami.com/collect/1243211545
https://m.xiami.com/collect/1243206771
https://emumo.xiami.com/collect/1243201762
https://m.xiami.com/collect/1243201762
https://emumo.xiami.com/collect/1243206771
https://m.xiami.com/collect/1243214502
https://emumo.xiami.com/collect/1243214502
https://m.xiami.com/collect/1243212517
https://emumo.xiami.com/collect/1243212517
https://m.xiami.com/collect/1243205794
https://emumo.xiami.com/collect/1243205794
https://m.xiami.com/collect/1243217380
https://emumo.xiami.com/collect/1243217380
https://m.xiami.com/collect/1243207745
https://emumo.xiami.com/collect/1243207745
https://m.xiami.com/collect/1243208725
https://emumo.xiami.com/collect/1243208725
https://m.xiami.com/collect/1243219321
https://emumo.xiami.com/collect/1243219321
https://m.xiami.com/collect/1243205792
https://emumo.xiami.com/collect/1243205792
https://m.xiami.com/collect/1243208722
https://emumo.xiami.com/collect/1243208722
https://m.xiami.com/collect/1243218333
https://emumo.xiami.com/collect/1243218333
https://m.xiami.com/collect/1243212511
https://emumo.xiami.com/collect/1243212511
https://m.xiami.com/collect/1243201757
https://emumo.xiami.com/collect/1243201757
https://m.xiami.com/collect/1243211537
https://emumo.xiami.com/collect/1243211537
https://m.xiami.com/collect/1243217373
https://emumo.xiami.com/collect/1243217373
https://m.xiami.com/collect/1243208717
https://emumo.xiami.com/collect/1243208717
https://m.xiami.com/collect/1243210615
https://emumo.xiami.com/collect/1243210615
https://m.xiami.com/collect/1243215446
https://emumo.xiami.com/collect/1243215446
https://m.xiami.com/collect/1243218331
https://m.xiami.com/collect/1243214491
https://m.xiami.com/collect/1243208715
https://emumo.xiami.com/collect/1243208715
https://m.xiami.com/collect/1239249619
https://emumo.xiami.com/collect/1239249619
https://m.xiami.com/collect/1239255372
https://m.xiami.com/collect/1239252562
https://m.xiami.com/collect/1239254487
https://m.xiami.com/collect/1239248597
https://m.xiami.com/collect/1239247633
https://m.xiami.com/collect/1239257330
https://m.xiami.com/collect/1239253539
https://m.xiami.com/collect/1239257324
https://m.xiami.com/collect/1239261128
https://m.xiami.com/collect/1239253534
https://m.xiami.com/collect/1239256354
https://m.xiami.com/collect/1239261123
https://m.xiami.com/collect/1239251564
https://m.xiami.com/collect/1239251562
https://m.xiami.com/collect/1239254475
https://m.xiami.com/collect/1239247621
https://m.xiami.com/collect/1239251559
https://m.xiami.com/collect/1239248590
https://m.xiami.com/collect/1239258264
https://m.xiami.com/collect/1239258263
https://m.xiami.com/collect/1239254473
https://m.xiami.com/collect/1239258261
https://m.xiami.com/collect/1239256347
https://m.xiami.com/collect/1239249597
https://m.xiami.com/collect/1239254472
https://m.xiami.com/collect/1239257314
https://m.xiami.com/collect/1239260155
https://m.xiami.com/collect/1239250555
https://m.xiami.com/collect/1239254471
https://m.xiami.com/collect/1239254470
https://m.xiami.com/collect/1239251553
https://m.xiami.com/collect/1239260154
https://m.xiami.com/collect/1239257313
https://m.xiami.com/collect/1239253520
https://m.xiami.com/collect/1239246619
https://m.xiami.com/collect/1239251549
https://m.xiami.com/collect/1239253517
https://m.xiami.com/collect/1239259262
https://m.xiami.com/collect/1239258254
https://m.xiami.com/collect/1239247617
https://m.xiami.com/collect/1239246618
https://m.xiami.com/collect/1239254464
https://m.xiami.com/collect/1239250548
https://m.xiami.com/collect/1239255354
https://m.xiami.com/collect/1239250547
https://m.xiami.com/collect/1239251529
https://emumo.xiami.com/collect/1239251529
https://m.xiami.com/collect/1239256322
https://emumo.xiami.com/collect/1239256322
https://m.xiami.com/collect/1239259241
https://emumo.xiami.com/collect/1239259241
https://m.xiami.com/collect/1239253497
https://emumo.xiami.com/collect/1239253497
https://m.xiami.com/collect/1239246596
https://emumo.xiami.com/collect/1239246596
https://m.xiami.com/collect/1239247601
https://emumo.xiami.com/collect/1239247601
https://m.xiami.com/collect/1239255333
https://emumo.xiami.com/collect/1239255333
https://emumo.xiami.com/collect/1239256315
https://emumo.xiami.com/collect/1239256314
https://m.xiami.com/collect/1239259236
https://emumo.xiami.com/collect/1239259236
https://m.xiami.com/collect/1239251525
https://emumo.xiami.com/collect/1239251525
https://m.xiami.com/collect/1239256314
https://m.xiami.com/collect/1239256315
https://m.xiami.com/collect/1239247595
https://m.xiami.com/collect/1239246581
https://m.xiami.com/collect/1239249556
https://m.xiami.com/collect/1239246576
https://m.xiami.com/collect/1239261083
https://m.xiami.com/collect/1239252522
https://m.xiami.com/collect/1239260113
https://m.xiami.com/collect/1239251516
https://m.xiami.com/collect/1239246574
https://m.xiami.com/collect/1239248530
https://m.xiami.com/collect/1239257272
https://m.xiami.com/collect/1239251509

上一篇:List的Stream流操作


下一篇:ORACLE批量处理数据之COLLECT BULK INTO 和FORALL的用法