2012年12月30日 星期日

安裝cuda 5.0

crtl+alt+F2

sudo service lightdm stop

sudo ./NVIDIA-Linux-x86_64-310.19.run

sudo ./cuda_5.0.35_linux_64_ubuntu11.10-1.run

vim ~/.bashrc

export PATH=/usr/local/cuda-5.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-5.0/lib:$LD_LIBRARY_PATH

2012年12月28日 星期五

打造自己的ubuntu

https://help.ubuntu.com/community/LiveCDCustomization

解壓縮 iso

Extract the CD .iso contents

Mount the Desktop .iso
mkdir mnt
sudo mount -o loop ubuntu-9.04-desktop-i386.iso mnt
Extract .iso contents into dir 'extract-cd'
mkdir extract-cd
sudo rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd

Extract the Desktop system

Extract the SquashFS filesystem

sudo unsquashfs mnt/casper/filesystem.squashfs
sudo mv squashfs-root edit


壓縮iso


sudo mksquashfs edit extract-cd/casper/filesystem.squashfs -b 1048576



2012年12月27日 星期四

WebGL(2)


第四章 Camera

These matrices represent transformations that when applied to our scene, allow us to move thing around.

matrices代表camera物件

每次移動camera,需要去更新4-4matrix根據camera新的位置

Homogeneous coordinate
h(x,y,z,w)=v(x/w,y/w,z/w)
v(x,y,z)=h(x,y,z,1)















View origin 視點eyecamera相對位於world origin
NDC(Normalize device Coordinate)
In NDC space, the x and y coordinate represent the location of your vertices on a normalized 2D scene, while the z-coordinate encodes depth information.

因為物件縮放,法向量不再垂直90度角
S'=MS
N'=KN
N'.S'=0
(KN).(MS)=0
(KN)^T(MS)=0
N^TK^TMS=0
N^T(K^TM)S=0
因為N^TS=0
所以K^TM=I







1.The Model-View Matrix that groups the model and view transform in one single matrix.
2.The Normal matrix is obtained by inverting and transposing the Model-View Matrix.
3.The perspective matrix groups the projection transformation and the perspective division.

uMVMatrix the model-view matrix
uPMatrix the perspective matrix
uNMatrix the normal Matrix














2012年12月24日 星期一

資料結構筆記(1)


The study of data structures therefore involves two complementary goals. The first goals is to identify and develop useful mathematical entities and operations and to determine what classes of problem can be solved by using these entities and operations.

The second goal is to determine representations for those abstract entities and to implement the abstract operations on these concrete representations.

將問題結構化成類別和操作,進而實作類別與操作以解決此問題

php上傳檔案


 <form action="UploadFile.php" method="post" enctype="multipart/form-data">
    請輸入要上傳的檔案:<input type="file" name="myFileID" /><br/>
    <input type="submit" value="上傳" />
 </form>



UploadFile.php


$szUpLoad = "./uploadfiles/";
if( $_FILES["myFileID"]["error"] == UPLOAD_ERR_OK )
{
    if( move_uploaded_file($_FILES["myFileID"]["tmp_name"],$szUpLoad.$_FILES["myFileID"]["name"]))
     {
        echo "成功";
    }
    else
    {
        echo "失敗\n";
        echo $_FILES["myFileID"]["error"];
    }
}

2012年12月23日 星期日

php 表單傳遞

file 1


<form action="login.php" target="_blank" method="post">
   帳號 <input type="text" name="name"><br>
   密碼 <input type="password" name="pwd"><br>
 <input type="submit" value="登入">

login.php

$_POST["name"]   //get 帳號值
$_POST["pwd"]      //get 密碼

2012年12月14日 星期五

Structure-deforming(變形) transformations--3D(1)


(x,y,z) undeformed vertex
(X,Y,Z) deformed vertex

X=Fx(x)
Y=Fy(y)
Z=Fz(z)

X=Sx(x)
Y=Sy(y)
Z=Sz(z)

X=xcosθ-γsinθ
Y=xsinθ+γcosθ
Z=z

θ=f5(z)

f'(z) specifies the rate of twist per unit length along the z axis







公式
X=x
Y={-sinθ(z-1/k)+γ0 γmin<=γ<=γmax
{-sinθ(z-1/k)+γ0+cosθ(γ-γmin) γ<γmin
{-sinθ(z-1/k)+γ0+cosθ(γ-γmax) γ>γmax
Z={-cosθ(z-1/k)+1/k+γ0 γmin<=γ<=γmax
{-cosθ(z-1/k)+1/k+γ0+sinθ(γ-γmin) γ<γmin
{-cosθ(z-1/k)+1/k+γ0+sinθ(γ-γmax) γ>γmax

velocity速度 V=(v1,v2,v3)

Addition of Vectors
X=T+W
=(x1,x2,x3)
=(v1+w1,v2+w2,v3+w3)

Length of Vectors
|V|=(v1^2+v2^2+v3^2)^1/2

U=v/|v| normalized V
v=|v|u

cross product of V and W

X=VхW
=(v2w3-v3w2)i+(v3w1-v1w3)j+(v1w2-v2w1)k

i=(1,0,0)
j=(0,1,0)
k=(0,0,1)

Q(u,v)為平面Q 任一點(u,v)

Ns=Q/u + Q/v

Np=V1x v2

Normal vector(法向量) and dot product

X=VW
=v1w1+v2w2+v3w3


cosθ=v∙w/|v||w|
|X|=|W|cosθ
=|W|∙V∙W/|V||W|
=V∙W


cosθ = v∙w/|v||w| 兩向量夾角
L入射光 R反射光



R=R1+R2
R1 = -L+R2
R=2R2-L
R2=(N∙L)N
R=2(N∙L)N – L


Precedence and associativity of Operators in C

運算子的優先性和結合性


Precedence and associativity of Operators
Operators
Associativity
() [] → .
Left to right
! ~ ++ – + - * & (type) sizeof
Right to left
* / %
Left to right
+ -
Left to right
<< >>
Left to right
< <= > >=
Left to right
== !=
Left to right
&
Left to right
^
Left to right
|
Left to right
&&
Left to right
||
Left to right
?:
Right to left
= += -= *= /= %= &= ^=
!= <<= >>=
Right to left
,
Left to right

線性代數

線性代數為linear system
但是現實生活為non linear system
也就是現實生活有一個數學模型來解決這個現實生活的問題