killykilly
12-13-2010, 04:54 PM
Hi ! I am trying to plot a line using the variables that I have derived in this "rectangular to polar" conversion program. I am just new to javascript and to programming generally. But with the help of sample codes here, I have managed to deal with some easy problems.
I have read that drawing in javascript isn't so easy. Could you give me some hints on how to draw the following variable in polar coordinates. Do I need to use another programming language aside from javascript ?
Thank you very much !!!
<html>
<head>
</head>
<body>
<script language="javascript" type="text/javascript">
function PolarConvert(){
num_1=Number(document.addition.entry_1.value);
num_2=Number(document.addition.entry_2.value);
valNum1=Math.pow(num_1,2);
valNum2=Math.pow(num_2,2);
valNum3=Math.sqrt(valNum1 + valNum2);
valNum4=Math.atan(num_2/num_1);
valNum5=(valNum4*180)/Math.PI;
document.addition.endVal.value=valNum3;
document.addition.endVal2.value=valNum5;
}
</script>
<form name="addition">
<input type="text" name="entry_1">+ j
<input type="text" name="entry_2"> =
<input type="text" name="endVal"> angle
<input type="text" name="endVal2"><br>
<input type="button" value="Convert to polar" onclick="PolarConvert()">
<input type="reset" value="Clear">
</form>
</body>
</html>
I have read that drawing in javascript isn't so easy. Could you give me some hints on how to draw the following variable in polar coordinates. Do I need to use another programming language aside from javascript ?
Thank you very much !!!
<html>
<head>
</head>
<body>
<script language="javascript" type="text/javascript">
function PolarConvert(){
num_1=Number(document.addition.entry_1.value);
num_2=Number(document.addition.entry_2.value);
valNum1=Math.pow(num_1,2);
valNum2=Math.pow(num_2,2);
valNum3=Math.sqrt(valNum1 + valNum2);
valNum4=Math.atan(num_2/num_1);
valNum5=(valNum4*180)/Math.PI;
document.addition.endVal.value=valNum3;
document.addition.endVal2.value=valNum5;
}
</script>
<form name="addition">
<input type="text" name="entry_1">+ j
<input type="text" name="entry_2"> =
<input type="text" name="endVal"> angle
<input type="text" name="endVal2"><br>
<input type="button" value="Convert to polar" onclick="PolarConvert()">
<input type="reset" value="Clear">
</form>
</body>
</html>