Results 1 to 12 of 12

Thread: Cos and Sin

  1. #1
    chenko
    Guest

    Cos and Sin

    Ok, ive already done my exams so i dont need to remember


    now which one do I use to work out the oposite sides (cant remember what they are called) of a triangle when i only have the angle and the length of the hypothonuse?


    Code:
      |\
      | \
      |  \
    a |   \  h
      |_   \
      |_|__(\ 
          b

  2. #2
    Addicted Member
    Join Date
    Mar 2001
    Posts
    157
    opposite: a = h sin angle
    adjacent: b = h cos angle

  3. #3
    chenko
    Guest
    a = Cos(Angle) * h
    b = Sin(Angle) * h

    thats what i got and it returns negative numbers most of the time

  4. #4
    Addicted Member
    Join Date
    Mar 2001
    Posts
    157
    If (angle mod 360) > 180 then h * sin (angle) will be negative.
    If (angle mod 360) > 90 and < 270 then h * cos (angle) will be negative.
    (Assuming h is positive)

  5. #5
    chenko
    Guest
    angle will always be greater than 0 and less than 90, it will NEVER be 0 or 90

    h is ALWAYS positive.


    what im trying to do is move one end of a line in a semi circle based on a perentage given to it ie. 25% is 45deg and as with a line you can specify the length or the angle i work the angle out from the percentage (percentage * 1.8)

    i have attacted my form.... ignore all the lines (they were there for other purposes) end even the circle, except the red and blue lines

    ive sorted the code to minus 90deg if it is over 90deg and mark in a varible (Acute_Angle) so that i know wether to add a (length on the X axis) to the postion of the center where the line meets its base line

    if ya dont understand anything just ask


    cheers
    Attached Files Attached Files

  6. #6
    chenko
    Guest
    what the hell?!?!?!

    Sin(30) returns : -0.988031624092862

    its supposed to be 0.5 !!!

  7. #7
    Addicted Member
    Join Date
    Mar 2001
    Posts
    157
    All trig calculations must be done in radians (360 deg = 2 * Pi radians)

    I've changed your form a little, is this what you wanted?
    Attached Files Attached Files

  8. #8
    chenko
    Guest
    that sorta works

    but if i put 0% it seams to start at 45deg and 100% is 135deg


    thanks lots for that!

  9. #9
    chenko
    Guest
    Originally posted by chenko
    thanks lots for that!

    sorry that sounded rude.


    if i put -50% it is set at 0deg and 150% = 180deg..... ummmm

  10. #10
    Addicted Member
    Join Date
    Mar 2001
    Posts
    157
    now 0%-> 0 deg.
    100%->180 deg.

    Hope this helps.

    It was odd before so the line pointed roughly towards the marks on the form.
    Attached Files Attached Files

  11. #11
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Haven't looked at the code but in case it's helpful, this function will convert from a percentage of 90 degrees to the equivalent in radians:

    VB Code:
    1. Function Percent2Radians(Percentage As Double) As Double
    2.     '90 / 100 * pi / 180 = 0.015707963267948966192313216916398
    3.     Percent2Radians = Percentage * 0.015707963267948966192313216916398
    4. End Function
    I'm not sure how accurate you can make that constant, round it down if it's too long.
    Harry.

    "From one thing, know ten thousand things."

  12. #12
    chenko
    Guest
    well i can easily convert degrees to radians

    thank you both anyways...

    I spent 3 days figuring that out *ahem* time wasting *ahem*


    thanks

    si

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