home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Nave / naval.swf / scripts / __Packages / CVector3D.as < prev   
Encoding:
Text File  |  2006-06-13  |  1008 b   |  55 lines

  1. class CVector3D
  2. {
  3.    var x;
  4.    var y;
  5.    var z;
  6.    function CVector3D(x_, y_, z_)
  7.    {
  8.       this.x = x_;
  9.       this.y = y_;
  10.       this.z = z_;
  11.    }
  12.    function reinit(x_, y_, z_)
  13.    {
  14.       this.x = x_;
  15.       this.y = y_;
  16.       this.z = z_;
  17.    }
  18.    function duplicate()
  19.    {
  20.       return new CVector3D(this.x,this.y,this.z);
  21.    }
  22.    function copyTo(v)
  23.    {
  24.       v.x = this.x;
  25.       v.y = this.y;
  26.       v.z = this.z;
  27.    }
  28.    function minus(v)
  29.    {
  30.       this.x -= v.x;
  31.       this.y -= v.y;
  32.       this.z -= v.z;
  33.    }
  34.    function plus(v)
  35.    {
  36.       this.x += v.x;
  37.       this.y += v.y;
  38.       this.z += v.z;
  39.    }
  40.    function multNew(num)
  41.    {
  42.       return new CVector3D(this.x * num,this.y * num,this.z * num);
  43.    }
  44.    function normalize()
  45.    {
  46.       var _loc2_ = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  47.       if(_loc2_ > 0.001)
  48.       {
  49.          this.x /= _loc2_;
  50.          this.y /= _loc2_;
  51.          this.z /= _loc2_;
  52.       }
  53.    }
  54. }
  55.