Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. cosine rule

cosine rule

Scheduled Pinned Locked Moved C#
help
4 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Captain Trips
    wrote on last edited by
    #1

    i'm bad enough at trigonometry without having to code it cosine rule is: b2=a2+c2- 2bccosA so: cosB=a2+c2-b2/2ac B=cos^-1(cosB) I'm having problems coding the last line,'cos^-1',any help appreciated

    S 1 Reply Last reply
    0
    • C Captain Trips

      i'm bad enough at trigonometry without having to code it cosine rule is: b2=a2+c2- 2bccosA so: cosB=a2+c2-b2/2ac B=cos^-1(cosB) I'm having problems coding the last line,'cos^-1',any help appreciated

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      I guess the follwoing is demanded:

      B = Math.Acos(cosB);


      www.troschuetz.de

      C 1 Reply Last reply
      0
      • S Stefan Troschuetz

        I guess the follwoing is demanded:

        B = Math.Acos(cosB);


        www.troschuetz.de

        C Offline
        C Offline
        Captain Trips
        wrote on last edited by
        #3

        my code looks like this,'A' should come out at about 70 degrees double sideA=6.75; double sideB=4.5; double sideC=6.7; double cosA=(Math.Pow(sideB,2) + Math.Pow(sideC,2) - Math.Pow(sideA,2)) / (2 * sideB * sideC); tried double A=Math.Acos(cosA);

        S 1 Reply Last reply
        0
        • C Captain Trips

          my code looks like this,'A' should come out at about 70 degrees double sideA=6.75; double sideB=4.5; double sideC=6.7; double cosA=(Math.Pow(sideB,2) + Math.Pow(sideC,2) - Math.Pow(sideA,2)) / (2 * sideB * sideC); tried double A=Math.Acos(cosA);

          S Offline
          S Offline
          Stefan Troschuetz
          wrote on last edited by
          #4

          And it does, if you pay attention to the information the documentation gives you. In this case you have to multiply the return value of Math.Acos by 180/Math.PI to convert it from radians to degrees.


          www.troschuetz.de

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups