Copy link to clipboard
Copied
Hey, I need help to use values from two different textboxes and show the result in the third box.
example:
Box1: 15 (adjacent)
Box2: 115 (hyptotenuse)
Box3: I need the sin angle
Anybody that can help me with the "Math.asin" code for this?
Thank u in advance!!
Copy link to clipboard
Copied
Why do I have the feeling we are doing your math homework? 🙂
The formula to determine the angle when the adjacent and hyotenuse are given, is cos(alpha) = adjacent/hypotenuse
So alpha = arccos(adjacent/hyponeuse)
To express that in JavaScript, we use the Math.acos function:
var adj = this.getField("Box1").value;
var hyp = this.getField("Box2").value;
event.value = Math.acos(adj/hyp);
You will use this as the custom calculation script for Box3. This code is not doing any error checking, so you may end up with an exception. I'll leave that up to you to add. Also, the angle is expressed in rad, so you will have to convert to degrees.
Copy link to clipboard
Copied
Thank You very much for taking the time to answer!
Hehe, This got nothing to do with math homework. Im a studentpilot and we use a navigation pdf form. And it takes so much time by plotting and calculating. Im trying to make the form as much as possible automatic with as few inputs.
I found a code on this support community and made some modifications and it work. The only problem I have is to get the angle from rad to deg. Could you be so kind to take the time to help me again?
The code I found and modified looks like this;
var v1 = Number(this.getField("TextField5").valueAsString);
var v2 = Number(this.getField("TextField6").valueAsString);
var v3 = Math.asin(v2/v1);
if (v3==0) event.value = "";
else event.value = v3;
Copy link to clipboard
Copied
Change this line "var v3 = Math.asin(v2/v1);" to this:
var v3 = Math.asin(v2/v1) * 180 / Math.PI;
Copy link to clipboard
Copied
One more thing: When you use asin, you are getting the ange for the opposite side, not the adjacent.
Copy link to clipboard
Copied
I know, I meant to write opposite side from the start. Thank you for answering and have a nice day!