• Global community
• Language:
• Deutsch
• English
• Español
• Français
• Português
• 日本語コミュニティ
Dedicated community for Japanese speakers
• 한국 커뮤니티
Dedicated community for Korean speakers
Exit
• Re: arcSin function in adobe

New Here ,
Oct 08, 2020 Oct 08, 2020

Copied

Hey, I need help to use values from two different textboxes and show the result in the third box.

example:

Box2: 115 (hyptotenuse)

Box3: I need the sin angle

Anybody that can help me with the "Math.asin" code for this?

TOPICS
Acrobat SDK and JavaScript

Views

349

Report

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

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

To express that in JavaScript, we use the Math.acos function:

``````var adj = this.getField("Box1").value;
var hyp = this.getField("Box2").value;

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.

Report

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

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;

Report

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

Copied

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

``var v3 = Math.asin(v2/v1) * 180 / Math.PI;``

Report

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

Copied

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

Report

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

Copied

LATEST

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