home *** CD-ROM | disk | FTP | other *** search
/ Champak 48 / cdrom_image.iso / Games / bobsleddin.swf / scripts / __Packages / Point.as < prev    next >
Encoding:
Text File  |  2007-09-28  |  1.1 KB  |  55 lines

  1. class Point
  2. {
  3.    var x = 0;
  4.    var y = 0;
  5.    function Point(x, y)
  6.    {
  7.       if(x || y)
  8.       {
  9.          this.x = x;
  10.          this.y = y;
  11.       }
  12.    }
  13.    function dot(_p)
  14.    {
  15.       return Math.sqrt(this.x * _p.x + this.y * _p.y);
  16.    }
  17.    function cross(_p)
  18.    {
  19.       return new Point(this.y,- this.x);
  20.    }
  21.    function getNormalized()
  22.    {
  23.       var _loc2_ = Math.sqrt(this.x * this.x + this.y * this.y);
  24.       return new Point(this.x / _loc2_,this.y / _loc2_);
  25.    }
  26.    function get magnitude()
  27.    {
  28.       return Math.sqrt(this.x * this.x + this.y * this.y);
  29.    }
  30.    function get length()
  31.    {
  32.       return Math.sqrt(this.x * this.x + this.y * this.y);
  33.    }
  34.    function normalize()
  35.    {
  36.       var _loc2_ = Math.sqrt(this.x * this.x + this.y * this.y);
  37.       this.x /= _loc2_;
  38.       this.y /= _loc2_;
  39.    }
  40.    function reverse()
  41.    {
  42.       this.x *= -1;
  43.       this.y *= -1;
  44.    }
  45.    function zero()
  46.    {
  47.       delete this.x;
  48.       delete this.y;
  49.    }
  50.    function toString()
  51.    {
  52.       return "Point (" + this.x + "," + this.y + ")";
  53.    }
  54. }
  55.