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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. tan() - gives incorrect result

tan() - gives incorrect result

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 3 Posters 0 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.
  • S Offline
    S Offline
    simon alec smith
    wrote on last edited by
    #1

    I am using the tan() function to rotate a coordinate the spacing between each increment (arc)are not equal Does anybody know why this is happening? thank you Simon

    C 1 Reply Last reply
    0
    • S simon alec smith

      I am using the tan() function to rotate a coordinate the spacing between each increment (arc)are not equal Does anybody know why this is happening? thank you Simon

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      How are you using it (please post the code)? :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      S 1 Reply Last reply
      0
      • C CPallini

        How are you using it (please post the code)? :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        S Offline
        S Offline
        simon alec smith
        wrote on last edited by
        #3

        here goes, all this for the first quadrant /////////////////////////// x = 0; y = 12; degreeIncrement = 0; for (---- about 30 times){ x = tan(degreeIncrement) * 12; ------>as 12 is the pyth theory (c square) ------> for the x position increment y' = (12.0 * 12.0) - (x * x); -------> then square root y y = sqrt(y); plot line from origin to x,y + position on screen m_degreeIncrement += 0.2; ------> or what ever value } end loop ////////////// Hope this helps, I am also aware of the cos, and sin functions formula Thanks Simon

        K 1 Reply Last reply
        0
        • S simon alec smith

          here goes, all this for the first quadrant /////////////////////////// x = 0; y = 12; degreeIncrement = 0; for (---- about 30 times){ x = tan(degreeIncrement) * 12; ------>as 12 is the pyth theory (c square) ------> for the x position increment y' = (12.0 * 12.0) - (x * x); -------> then square root y y = sqrt(y); plot line from origin to x,y + position on screen m_degreeIncrement += 0.2; ------> or what ever value } end loop ////////////// Hope this helps, I am also aware of the cos, and sin functions formula Thanks Simon

          K Offline
          K Offline
          Kentamanos
          wrote on last edited by
          #4

          Having a hard time following the logic on your math. You're multiplying the tangent by 12, which appears to be the length of the hypotenuse since you using it later in what looks like the Pythagorean theorem. Since tangent has no relation to the hypotenuse, I'm not sure why you're doing that. (tangent = opposite / adjacent). I'm not sure what you're trying to do, but if it's drawing "spokes" (like a wagon wheel) from the origin to various angles, then why wouldn't you just use something like: x = length * cos(currentAngle) y = length * sin(currentAngle) And sweep thru the angles you want to cover?


          I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
          -David St. Hubbins

          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