fc2ブログ

三次元変換行列(7)

2008/05/13 21:31 - AS3.0



平行移動(translate)


  1. 新規に Matrix3D オブジェクトを生成
  2. その新規行列の当該成分に対して当該値を代入
  3. 現在の行列との合成

/**
* 平行移動
* | 1  0  0  dx |
* | 0  1  0  dy |
* | 0  0  1  dz |
* | 0  0  0  1  |
*/
public function translate(
            dx:Number,
            dy:Number,
            dz:Number ):void {
 var mat:Matrix3D = new Matrix3D();
 mat.tx = dx;
 mat.ty = dy;
 mat.tz = dz;
 concat( mat );
}




| 1  0  0  0 |
| 0  1  0  0 |
| 0  0  1  0 |
| 0  0  0  1 |
a * I = I * a = a

  単位行列     平行移動
| 1  0  0  0 |  | 1  0  0  dx |
| 0  1  0  0 |  | 0  1  0  dy |
| 0  0  1  0 |  | 0  0  1  dz |
| 0  0  0  1 |  | 0  0  0  1  |

| na  nb  nc  ntx |   | 1  0  0  dx |   | a  b  c  tx |
| nd  ne  nf  nty | = | 0  1  0  dy | * | d  e  f  ty |
| ng  nh  ni  ntz |   | 0  0  1  dz |   | g  h  i  tz |
| 0   0   0   1   |   | 0  0  0  1  |   | 0  0  0  1  |

↓

na  = 1*a  + 0*d  + 0*g  + dx*0;
nb  = 1*b  + 0*e  + 0*h  + dx*0;
nc  = 1*c  + 0*f  + 0*i  + dx*0;
ntx = 1*tx + 0*ty + 0*tz + dx*1;

nd  = 0*a  + 1*d  + 0*g  + dy*0;
ne  = 0*b  + 1*e  + 0*h  + dy*0;
nf  = 0*c  + 1*h  + 0*i  + dy*0;
nty = 0*tx + 1*ty + 0*tz + dy*1;

ng  = 0*a  + 0*d  + 1*g  + dz*0;
nh  = 0*b  + 0*e  + 1*h  + dz*0;
ni  = 0*c  + 0*f  + 1*i  + dz*0;
ntz = 0*tx + 0*ty + 1*tz + dz*1;

↓

na  = a;
nb  = b;
nc  = c;
ntx = tx + dx;

nd  = d;
ne  = e;
nf  = f;
nty = ty + dy;

ng  = g;
nh  = h;
ni  = i;
ntz = tz + dz;
public function translate(
            dx:Number,
            dy:Number,
            dz:Number ):void {
 _tx += dx;
 _ty += dy;
 _tz += dz;
}


にほんブログ村 IT技術ブログへ



スポンサーサイト




コメントの投稿

非公開コメント

タグクラウド

最近の記事
カテゴリ
月別アーカイブ
プロフィール

Aquioux

Author:Aquioux
日曜 Flash プログラマ。
Flash 作品は本館で展示しています。


mailto:aquioux@mail.goo.ne.jp

ブログパーツ

あわせて読みたい

フィードメーター - 閃光的網站・弛緩複合体 -Review Division-


検索/translation
Google



オススメ本

コメント
トラックバック
RSS

Add to Google

Bloglinesで閲読登録

はてなRSSに追加

Subscribe with livedoor Reader

My Yahoo!に追加

Add to Technorati Favorites!

feedpathに追加