Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function calculatePolar(){
- var x = $F('x');
- var y = $F('y');
- var r = Math.pow((Math.pow(x,2) + Math.pow(y,2)),0.5);
- var theta = Math.atan(y/x)*360/2/Math.PI;
- if (x >= 0 && y >= 0) {
- theta = theta;
- } else if (x < 0 && y >= 0) {
- theta = 180 + theta;
- } else if (x < 0 && y < 0) {
- theta = 180 + theta;
- } else if (x > 0 && y < 0) {
- theta = 360 + theta;
- }
- //Box.ajaxReq('/docs/scripts/conv.js',false);
- var msg = ""
- + "Polar Coordinates (" + Conv.rounding(r) + ", " + Conv.rounding(theta) + ")\n"
- + "";
- alert(msg);
- }
- function calculateCartesian(){
- var r = $F('r');
- var theta = $F('theta');
- var x = r * Math.cos(theta * 2 * Math.PI / 360);
- var y = r * Math.sin(theta * 2 * Math.PI / 360);
- //Box.ajaxReq('/docs/scripts/conv.js',false);
- var msg = ""
- + "Cartesian Coordinates (" + Conv.rounding(x) + ", " + Conv.rounding(y) + ")\n"
- + "";
- alert(msg);
- }
Advertisement
Add Comment
Please, Sign In to add comment