i need to take the sin of an angel in degrees but VB does it in radians
so, how do i get VB to calculate trig functions in degrees instead of radians?
Printable View
i need to take the sin of an angel in degrees but VB does it in radians
so, how do i get VB to calculate trig functions in degrees instead of radians?
Code:Pi= 3.141592654
AngleR = AngleD * Pi / 180
AngleD = AngleR * 180 / Pi
i don't understand how i am supposed to use that code
this is what i got:
a is the angle in degrees
s is the initian speed of the object
dh is really dh/dt, the rate of change of the height of the object with respect to time
a=45
dh=sin(a)*s
i need that dh (dh/dt) value for a formula,
my problem is it calculates sin(45) as .850935 when sin(45) in degrees is .7071
Convert the angle to radians THEN pass it to the trig functions. VB, like most things you'll encounter, uses radians because they are a much more practical type (they're based on REAL properties of a circle as opposed to the "hey, let's have 360 degrees in this thing" method) :)
Code:
AngleD is the angle in degrees and AngleR in Radians
Type:
dh=sin(a * Pi / 180) * s
...Code:Function Deg2Rad(dAngle As Double)
Deg2Rad = dAngle * (Pi / 180)
End Function
Code:Debug.Print Sin(Deg2Rad(45))
The parentisis aren't needed: Deg2Rad = dAngle * Pi / 180Quote:
Originally posted by parksie
...Code:Function Deg2Rad(dAngle As Double)
Deg2Rad = dAngle * (Pi / 180)
End Function
It doesn't really matter...:rolleyes:
Yeah, but I put them in because in my code I usually define the constant PIDIV180 to save VB having to recalculate it each time ;)
If you don't have a good memory of the value of pi
like me :D use...
Pi = 4*Atn(1)
thanks guys, that code did the trick
my prog. works fine now