home *** CD-ROM | disk | FTP | other *** search
- class Point
- {
- var x = 0;
- var y = 0;
- function Point(x, y)
- {
- if(x || y)
- {
- this.x = x;
- this.y = y;
- }
- }
- function dot(_p)
- {
- return Math.sqrt(this.x * _p.x + this.y * _p.y);
- }
- function cross(_p)
- {
- return new Point(this.y,- this.x);
- }
- function getNormalized()
- {
- var _loc2_ = Math.sqrt(this.x * this.x + this.y * this.y);
- return new Point(this.x / _loc2_,this.y / _loc2_);
- }
- function get magnitude()
- {
- return Math.sqrt(this.x * this.x + this.y * this.y);
- }
- function get length()
- {
- return Math.sqrt(this.x * this.x + this.y * this.y);
- }
- function normalize()
- {
- var _loc2_ = Math.sqrt(this.x * this.x + this.y * this.y);
- this.x /= _loc2_;
- this.y /= _loc2_;
- }
- function reverse()
- {
- this.x *= -1;
- this.y *= -1;
- }
- function zero()
- {
- delete this.x;
- delete this.y;
- }
- function toString()
- {
- return "Point (" + this.x + "," + this.y + ")";
- }
- }
-