Wha is this program doing?

var p={
x:1.0,
y:1.0,

get r(){
return Math.sqrt(this.x*this.x+this.y*this.y);
},
set r(newvalue){
var oldvalue=Math.sqrt(this.x*this.x+this.y*this.y);
var ratio=newvalue/oldvalue;
this.x*=ratio;
this.y*=ratio;
},
get theta(){
return Math.atan2(this.y, this.x);
}
};


I do know what polar coordinates are.
p.r returns the distance between (1,1) and (0,0) which is Math.sqrt(2).
Math.atan2 returns the angle.
What does setting p.r do though?
I can follow the math on paper but I don't understand the logic behind it.
This is JavaScript.

Attached: 1551046693923.jpg (966x2604, 1.57M)

Other urls found in this thread:

developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get
developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set
twitter.com/NSFWRedditGif

not doing your homework for you without something in return

lol dis nigga want the succ

And this is not homework.
I am reading about getters and setters.

developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get
developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set

Those feet are gnarly.

p,r returns the magnitude of the vector.

now go do your own homework nigger

It is clearly written in OP.
Can you read?

Attached: 1549549827906.jpg (736x736, 164K)

shut the fuck up rajesh

I'd suck that freezie.

just pay for chegg, motherfucker!