I know Cos is Cosine and Sin is Sine but what do they do??
Cos( 4 * 5 )
BTW this is Visual Basic
Printable View
I know Cos is Cosine and Sin is Sine but what do they do??
Cos( 4 * 5 )
BTW this is Visual Basic
Cos(x) and sin(x)
They return the trigonometric value of the cosine and sine of x radians respectively. If you don't know what radians are, i suggest going to the wolfram site, or just google.
cos(4*5)
= cos(20 radians)
if you want cos(20 degrees)
just do something like:
[Highlight=VB]
Pubilc Function DegCos(Byval x as double)
Dim Rad_to_Deg as double
Rad_to_Deg = 3.14159/180
DegCos= cos(x * Rad_to_Deg)
[/code]
based on the fact that 180 degrees = Pi radians, so Degcos(180) = cos(180*pi/180) = cos(pi) in radians = cos(180) in degrees
Ill try and take all that in, i am only 13 so ill keep trying to fiddle with it.
Goodluck with the code. I guess that's what you meant.
VB always using Radians instead of degrees can be REALLY annoying sometimes, espescially if you work out stuff by hand in Degrees, but then have to convert back to Radians. At least it doesn't use Gradiants :p that would be even worse.
BTW: i myself am only 15, but i guess 2 years is a long time when it is more than 10% of your (and my) life :D
radians are a much more logical system than degrees are though, and its easy to work with them once you get used to it. The advantage to radians is that they are directly compatible with formulas like 2*pi*R and pi*R^2.
The disadvantage is its subdivision unit is an irrational number, so 45 Degrees expressed in radians is {If PI = 180 degrees} = PI/4.Quote:
Originally posted by glyptar
radians are a much more logical system than degrees are though, and its easy to work with them once you get used to it. The advantage to radians is that they are directly compatible with formulas like 2*pi*R and pi*R^2.
Imagine Navigating a ship in Radians!
"Helmsman, Take us PI Sixtyieths Radians to the Starboard Side"
:p
They give you information about missing parts of triangles that you want to calculate, For example, you can use them to draw a circle
Code:' draw a red circle in a picture box
const PI = 3.14159265358979 ' some decimals whacked off
const radius = 95
const shift = 200 ' shift everything up and over 200 pixels.
Dim x as double, y as double,angle as double
Dim xlong as long, ylong as long
Dim retval as long
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, _
ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
for angle=0 to PI*2 step (2*PI)/(1/360) ' step by degrees
x=cos(angle)*radius
y=sin(angle)*radius
xlong=cLng(x)
ylong=Clng(y)
retval=SetPixel(Picture1.hDC,xlong,ylong, vbRed)
next
true, but thats why my VB helmsman can make calculations all on his own :p
Whats wrong with the good old:
"form1.circle (100,100), 100"
sql_lall - nothing I was showing how the circle method did it's job.
I cannot give you a complete trig course here, but following are a few hints.
Imagine a right triangle with a hypotenuse (longest side) equal to 2, and one of the shorter sides equal to 1. The third side is equal to SquareRoot(3).
The Sine of the angle opposite the shortest side is 1/2, and the Cosine of that angle is SquareRoot(3)/2.
The Sine and Cosine are ratios of triangle sides. If you know one angle of a right triangle and the hypotenuse, you can use the Sine & Cosine Functions to determine the lengths of the short sides.
Sine & Cosine appear in a lot of formulae, and have uses other than the above.
In a 3, 4, 5 Right triangle, the following are true.
Sine(SmallerAngle) = 3/5
Cosine (SmallerAngle) = 4/5
Tangent(SmallerAngle) = 3/4
Sine(BiggerAngle)= 4/5
Cosine(BiggerAngle)= 3/5
Tangent(BiggerAngle)= 4/3