Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I calculate acos in vb? 1

Status
Not open for further replies.

navyguy

Mechanical
Joined
Aug 13, 2002
Messages
5
Location
US
I have an equation to be calculated in vb that requires me to calculate the acos of a value. There doesn't seem to appear to be an acos function in vb. I heard you can do some trick with atan. Does anyone know that trick or have any suggestions?

Thanks
 
Two ways:

1. If your VBA code is for an excel application, use
application.acos(angle)
With the "application" in front, VBA will reckognize the excel functions.

2. If not, derive function via atn() as described in the VBAhelp (browse for help on cos, and press "see also"):


Derived Math Functions

The following is a list of nonintrinsic math functions that can be derived from the intrinsic math functions:

Function Derived equivalents
......
Inverse Cosine Arccos(X) = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
......

Hope this helps

Regards
Mogens
 
Just to add on

When x = 1, Arccos(x) = 0

When x = -1 Arccos (x) = 4 * Atn(1)

Regg [smile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top