// (c) 2007 KystAtlas AS (Hans Martin Mohn)

gtPoint.prototype.set=function(x,y)
{this.x=x;this.y=y;return this;};gtPoint.prototype.newCopy=function()
{return new gtPoint(this.x,this.y);};gtPoint.prototype.setFromString=function(p)
{var pt=p.split(",");this.x=parseFloat(pt[0]);this.y=parseFloat(pt[1]);return this;};gtPoint.prototype.setToSum=function(rhs)
{this.x+=rhs.x;this.y+=rhs.y;return this;};gtPoint.prototype.setToMiddle=function(rhs)
{this.x=(this.x+rhs.x)/2.0;this.y=(this.y+rhs.y)/2.0;return this;};gtPoint.prototype.setToMiddleOf=function(p1,p2)
{this.x=(p1.x+p2.x)/2.0;this.y=(p1.y+p2.y)/2.0;return this;};gtPoint.prototype.newMiddle=function(rhs)
{return new gtPoint((this.x+rhs.x)/2.0,(this.y+rhs.y)/2.0);};gtPoint.prototype.length=function()
{return Math.sqrt(this.x*this.x+this.y*this.y);};gtPoint.prototype.distanceTo=function(rhs)
{var h=rhs.x-this.x;var v=rhs.y-this.y;return Math.sqrt(h*h+v*v);};gtPoint.prototype.dot=function(rhs)
{return this.x*rhs.x+this.y*rhs.y;};gtPoint.prototype.setToNormalized=function()
{var len=this.length();this.x/=len;this.y/=len;return this;};gtPoint.prototype.setToNormalOf=function(other)
{this.x=-other.y;this.y=other.x;return this;};gtPoint.prototype.newNormal=function()
{return new gtPoint(-this.y,this.x);};gtPoint.prototype.angleTo=function(rhs)
{var v1=Math.atan2(this.x,this.y);var v2=Math.atan2(rhs.x,rhs.y);var v=(v2-v1)*180.0/Math.PI;return(v>0)?v:v+360;};gtPoint.prototype.newVectorTo=function(rhs)
{return new gtPoint(rhs.x-this.x,rhs.y-this.y);};gtPoint.prototype.setToVector=function(a,b)
{this.x=b.x-a.x;this.y=b.y-a.y;return this;};gtPoint.prototype.setToReversed=function()
{this.x=-this.x;this.y=-this.y;return this;};gtPoint.prototype.newReversed=function()
{return new gtPoint(-x,-y);};gtPoint.prototype.setToScaled=function(k)
{this.x*=k;this.y*=k;return this;};gtPoint.prototype.newScaled=function(k)
{return new gtPoint(this.x*k,this.y*k);};function gtPoint(x,y)
{if(typeof(x)!="undefined"&&typeof(y)!="undefined")
{this.x=x;this.y=y;}
else
{this.x=0;this.y=0;}
return this;}