|
-
Feb 1st, 2012, 03:07 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Sin and Cos
I have problem,
I have 3 textbox for input degree, minutes and Second.
I want to calculate the 'dipat' and 'latit'. How to input the degree minutes and second from the textbox into the Sin and Cos?
Code:
Dim jarak As Double
Dim Degree As Integer
Dim Min As Integer
Dim Sec As Integer
Dim latit As Double
Dim dipat As Double
Degree = Val(Text1.Text)
Min = Val(Text2.Text)
Sec = Val(Text3.Text)
jarak = Val(Text4.Text)
dipat = jarak * Sin(Degree, Min, Sec)
latit = jarak * Cos(Degree, Min, Sec)
-
Feb 1st, 2012, 04:14 AM
#2
Re: Sin and Cos
Sin and Cos take an angle(in radians) as input. So you have to compute your angle(degrees) out of "Degree", "Min" and "Sec", convert it to a Radian and then use it in Sin or Cos
BTW A whole cirlce in Degree in 360° in Radians 2*Pi
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Feb 1st, 2012, 12:36 PM
#3
Re: Sin and Cos
Matrick
Building on Opus's post, you'll need to define Pi.
From MSDN
To convert degrees to radians, multiply degrees by pi/180.
You might find that using 3.1415927 is sufficiently
accurate for your purposes. If so, then you can then
use the built-in Sin and Cos functions as follows
Code:
nPI = 3.1415927
nDeg = Degree + Min / 60 + Sec / 3600
nRad = nDeg * (nPI / 180)
'
dipat = jarak * Sin(nRad)
latit = jarak * Cos(nRad)
Spoo
-
Feb 1st, 2012, 05:36 PM
#4
Re: Sin and Cos
Just curiosity: are you trying to get azimuth/distance from some given points on earth?
-
Feb 2nd, 2012, 03:12 AM
#5
Re: Sin and Cos
 Originally Posted by Spoo
You might find that using 3.1415927 is sufficiently
accurate for your purposes.
If it's not then: PI = 4 * Atn(1) is a reasonable approximation
-
Feb 2nd, 2012, 05:12 AM
#6
Member
Re: Sin and Cos
Try This:
PI = 3.14159265358979
TRIG = PI / 180
AD = Val(Text1.Text)
AM = Val(Text2.Text)
ASEC = Val(Text3.Text)
Jarak=Val(text4.text)
L = AD + AM / 60 + ASEC / 3600
dipat=jarak*sin(L)*trig
Best Regards
Sunil
-
Feb 2nd, 2012, 08:19 PM
#7
Re: Sin and Cos
Note that Pi (the ratio of the circumference of a circle to its diameter) can be approximated very accurately by just dividing 355 by 113. For most applications, that works very well. One has to wonder why we learned 22/7 in grammar school, when 355/113 was always available and far more accurate. Any ideas why 22/7 is still being taught? 
On the other hand, I've been using Doogle's VB6 solution for years.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|