Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

arcSin function in adobe

New Here ,
Oct 08, 2020 Oct 08, 2020

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!! 

TOPICS
Acrobat SDK and JavaScript
534
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2020 Oct 08, 2020

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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 08, 2020 Oct 08, 2020

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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2020 Oct 08, 2020

Change this line "var v3 = Math.asin(v2/v1);" to this:

 

var v3 = Math.asin(v2/v1) * 180 / Math.PI;
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2020 Oct 08, 2020

One more thing: When you use asin, you are getting the ange for the opposite side, not the adjacent. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 08, 2020 Oct 08, 2020
LATEST

I know, I meant to write opposite side from the start. Thank you for answering and have a nice day!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines