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.
are you retarded to now understand such simple issue?
Noah Long
p.r is the method. it's the actual r method, nothing else. Now invoking the method and getting its result is a different topic
Caleb Rodriguez
Are you fucking serious right now? This is CS 101 shit. If you really can't understand this you need to switch majors
Julian Hernandez
It's doing this
Robert Mitchell
>> >Jow Forums is NOT your personal tech support team or personal consumer review site. fuck off now
Gabriel Rivera
Why are the posters on this board so retarded? No one has given a proper answer yet. You'd need to input both r and theta to find x and y. The program should have something like: this.x=r*Math.cos(theta); this.y=r*Math.sin(theta); in it.
It keeps theta from the previous result you absolute mongoloid.
Jackson Thompson
this isn't even undergrad intro level, you are supposed to know what's vector and scalar multiplication already
Isaiah Davis
>It keeps theta from the previous result you absolute mongoloid. The trisomy 21 is strong with you. theta is calculated on the spot from the values of x and y. The way in which the program sets the values of x and y starting from r does not make sense.
Henry Clark
Go to tutoring if you need help with your fucking home work
Dylan Perez
are you really that stupid?
Brayden Martinez
Read the code again, carefully.
Zachary Harris
what the fuck are you talking about?
Hudson Clark
Change majors now, seriously, this is your last chance.
Austin James
or better: consider manual work
Mason Gonzalez
>Read the code again, carefully. I did. Let's test it. p.r=1; console.log(p.x); console.log(p.y); console.log(p.theta);
Can I get ONE single answer which explains what the function set r(newvalue) is doing?
Robert Clark
Now call the change r method and check the new coordinates. Then
Kevin Edwards
returns the fucking magnitude and angle of a 2D vector u cunt ass faggot bitch faggot fuck
FFS what kind of shit ugly pussy faggot beta language is that anyways
Tyler Gutierrez
It changes r without changing theta. Holy fucking shit user, get a grip.
Landon Roberts
>get r() pythagoreans theorum >set r(newvalue) scale x and y >get theta() calculates an angle by taking the arctan, not sure if its in degrees or radians, its ambiguous. but im guessing its in radians because its atan2 and not atan
Alexander Gonzalez
obviously 1/sqrt(2) can't you read that fucking code?
Jacob Campbell
yes brah
//initialize some variable called oldvalue to the magnitude of the old 2D vector oldvalue=Math.sqrt(this.x*this.x+this.y*this.y);
//initialize some variable called value to be equal to the ratio between the new value which was passed to the set r function over the old value which ws just calculated var ratio=newvalue/oldvalue;
//multiply the x and y coordinates of the 2D vector by this ratio. this.x*=ratio; this.y*=ratio;
Essentially this function lets u pass in a new desired magnitude for the vector, then it recalculates the new required x and y coordinates
>scale x and y Thank you so much. This is the only answer that makes sense. All of the others posters in this thread have shit for brains.
Liam Long
initialize some variable called ratio* my bad some typos in there on my phone
Aaron Clark
And what do you think scaling x and y does, retard?
Wyatt Brown
I’d suck the polish off those toes.
Chase Johnson
Using the program you can find r and theta invoking the functions. I assumed that he was somewhat trying to set value for x and y given the polar coordinates. Now you can resize it via setting r which indeed gives you new values for x and y, but theta remains the same. Reading that the program was doing nothing more than resizing (x,y) made me understand that my assumptions were wrong. I doesn't go from polar to Cartesian and vice versa.
Isaac Williams
* somehow This meant for
Nolan Foster
>Now you can resize it via setting r which indeed gives you new values for x and y, but theta remains the same. And how many times were you told that?
Colton Lopez
After >It changes r without changing theta. Holy fucking shit user, get a grip. Really. Which was the answer to my >What does setting p.r do though? What is that difficult answering immediately? I was trying to figure out how he was addressing theta.
Noah Murphy
>Wha is this program doing? throw an error if x = y = 0 and set r is used.
Ayden Perry
Looks like nobody cares what it does, kiddo. Got another dollar? Try again kiddo