オブジェクトの全頂点を回転させて、ノーマルも回転させる
角度を一律に与える場合
● オフセットが無い場合
・クーオータニオンの設定
vector4 q=quaternion(回転量,回転軸);
・回転
vector v=qrotate(q,頂点座標);
・頂点座標=v
● ピボット毎にオフセットする場合
・vector v=qrotate(q,頂点座標-ピボット座標);
・頂点座標=v+ピボット座標
Z軸回転のサンプル
//--- rot value ---
float val=chf("val");
//--- to (x,y) and (-y,x) ---
float Rx= cos(val);
float Ry= sin(val);
vector2 V0=set(Rx,Ry);
vector2 V1=set(-Ry,Rx);
//--- rot poinr normal ---
vector2 Vn=set([email protected],[email protected]);
float Dv0= dot(Vn,V0);
float Dv1=dot(Vn,V1);
vector VDn=set(Dv0,Dv1,[email protected]);
v@N=VDn;
//--- rot point position ---
vector2 Vp=set([email protected],[email protected]);
float Dp0 = dot(Vn,V0);
float Dp1 = dot(Vn,V1);
vector VDp=set(Dp0,Dp1,[email protected]);
v@P=VDp;
// normal is vector from "point".
// not vector from "wolrld center" or "object center".
頂点ノーマルを回転軸に沿ってクオータニオンでのPoint座標回転
//--- rotation value ---
float angle=radians(@Frame);
//---set rotatin axsis ---
vector vect=v@N;
//---get quaternion ---
vector4 q=quaternion(angle,vect);
//--- if offset x=2 ---
vector offs=set(2,0,0);
//---set vector to position ---
vector pos=v@P-offs;
vector v=qrotate(q,pos);
v@P=v;
ピボットと回転軸に沿ってクオータニオンでのPoint座標回転
//--- rotation value ---
float angle=radians(@Frame);
//---set rotatin axsis ---
vector vect=set(0,0,1);
//---get quaternion ---
vector4 q=quaternion(angle,vect);
//---set rotatin pivot ---
vector pivot= set(2,0,0);
//---set vector to position ---
vector pos=v@P-pivot;
vector v=qrotate(q,pos);
v@P=v;
複数のピボットと回転軸に沿ってクオータニオンでのPoint座標&ノーマル回転
//--- rotation value ---
float angle=radians(@Frame);
//---set rotatin axsis ---
vector vect=set(1,0,0);
//---get quaternion ---
vector4 q=quaternion(angle,vect);
//---set rotatin pivot ---
vector pivot=v@CdCnt;
//---set vector to position ---
vector pos=v@P-pivot;
vector v=qrotate(q,pos);
//---rot pos ---
v@P=v+pivot;
//---rot normal ---
v@N=qrotate(q,v@N);