scilab (http://www.scilab.org/) 是一款免費的,類似於matlab的軟體。
進行矩陣運算的時候比較方便。
opengl的三維座標系中, 分別繞 x, y, z 三座標軸旋轉xangle, yangle, zangle之後的旋轉矩陣,可以用下列公式計算。
function [ glrotatematrix ] = glrotatematrix( xangle, yangle, zangle )
// convert angle to radius
thetax = xangle * ( %pi / 180.0 );
thetay = yangle * ( %pi / 180.0 );
thetaz = zangle * ( %pi / 180.0 );
rx = [
1 0 0
0 cos( thetax ) -sin( thetax )
0 sin( thetax ) cos( thetax )
];ry = [
cos( thetay ) 0 sin( thetay )
0 1 0
-sin( thetay ) 0 cos( thetay )
];rz = [
cos( thetaz ) -sin( thetaz ) 0
sin( thetaz ) cos( thetaz ) 0
0 0 1
];glrotatematrix = rx * ry * rz;
endfunction
使用方法:
// v 是極其手臂的位置。
-->v =
-->glrotatematrix(30, 45, 0) * v
ans =
5.6568542
- 2.8284271
4.8989795
用scilab 畫軌跡
最近,需要用scilab來畫軌跡。自己做了乙個簡單的畫軌跡函式 函式如下 function x,y trajectory filename fid mopen filename,r if fid 1 error cannot open file for reading endcount 1 whil...
OpenGL(3) OpenGL視角的計算
oepngl繪圖的過程中,讓camera指向正確的方向比較容易,然而,在使用投影函式的過程中,一定要把物體放在裁剪範圍之內,當繪製出來的物體大小不合適的時候,可能是由於使用了glperspective 函式導致的,可以通過修改函式第乙個引數的值來調整大小。那麼第乙個引數的角度 視角 是如何確定的呢?...
OpenGL 光照方程的計算
分析程式並計算,請看下面的一段程式,並計算三個頂點1 2和3處的光照的顏色值。必須寫出過程,只有結果不得分。include void init void glfloat mat diffuse glfloat mat emission glfloat mat specular glfloat mat...