Triginomic functions in VBA

J

Jack Leach

Hi,

This isn't *exactly* a VBA question, but I'm hoping someone here might be
able to answer, as I can't seem to find the info anywhere else.

Triginomic functions in vba return an answer in Radians... is there a way
to get this in decimal values?


For example, as far as I know, the Tangent of an angle of 45° is 1. The
Cosine of 45° is 0.707106...

But in VBA,
?tan(45)
1.61977519054386

?cos(45)
0.52532198881773

whereas my TI Calculator and my reference (Machinery's Handbook) state that:
Tan(45) = 1
Cos(45) = 0.707106781

I understand that VBA returns these values in Radians rather than decimal
value... is there a way to get the decimal value for these triginomic
functions rather than the Radians?

Thanks,

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
D

Daniel Pineault

The trig function, from my knowledge, expect radian values passed to them and
not degrees. That is why cos(45) does not give you the expected result. Now
if you convert 45Deg into rads = 0.785398156722886 then the
cos(0.785398156722886 ) does equal 0.707....

So you need to use a conversion function such as:
http://www.devx.com/vb2themax/Tip/19029

or do something like:
? cos(YourAngleInDegrees / 57.29578)

--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
J

Jack Leach

Option Compare Database
Option Explicit

Public Function dTan(dblAngle As Double) As Double
dTan = Tan(dblAngle / (180 / PI()))
End Function

Public Function dCos(dblAngle As Double) As Double
dCos = Cos(dblAngle / (180 / PI()))
End Function

Public Function dSin(dblAngle As Double) As Double
dSin = Sin(dblAngle / (180 / PI()))
End Function

Public Function PI() As Double
PI = 4 * Atn(1)
End Function




These all work good. You can't put PI in a constant and have these work
correctly (ex Tan(45) will equal .9999999988) but the function returns
everything as it will up to about 20 decimal places at least.

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top