Results 1 to 11 of 11

Thread: Cos, Sin

  1. #1

    Thread Starter
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Cos, Sin

    I know Cos is Cosine and Sin is Sine but what do they do??

    Cos( 4 * 5 )


    BTW this is Visual Basic

    Visual Studio 6, Visual Studio.NET 2005, MASM

  2. #2
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Talking OK... Radians

    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
    sql_lall

  3. #3

    Thread Starter
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    Ill try and take all that in, i am only 13 so ill keep trying to fiddle with it.

    Visual Studio 6, Visual Studio.NET 2005, MASM

  4. #4
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Talking hehe...

    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 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
    sql_lall

  5. #5
    Addicted Member glyptar's Avatar
    Join Date
    Sep 2002
    Location
    The Netherlands
    Posts
    138
    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.
    Glyptar

  6. #6
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397
    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.
    The disadvantage is its subdivision unit is an irrational number, so 45 Degrees expressed in radians is {If PI = 180 degrees} = PI/4.

    Imagine Navigating a ship in Radians!

    "Helmsman, Take us PI Sixtyieths Radians to the Starboard Side"


  7. #7
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    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

  8. #8
    Addicted Member glyptar's Avatar
    Join Date
    Sep 2002
    Location
    The Netherlands
    Posts
    138
    true, but thats why my VB helmsman can make calculations all on his own
    Glyptar

  9. #9
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Wink Hmmm... complicated

    Whats wrong with the good old:
    "form1.circle (100,100), 100"
    sql_lall

  10. #10
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    sql_lall - nothing I was showing how the circle method did it's job.

  11. #11
    Frenzied Member
    Join Date
    Jul 1999
    Location
    Huntingdon Valley, PA 19006
    Posts
    1,151
    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
    Live long & prosper.

    The Dinosaur from prehistoric era prior to computers.

    Eschew obfuscation!
    If a billion people believe a foolish idea, it is still a foolish idea!
    VB.net 2010 Express
    64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width