• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Need help with a simple math task in C++

    Discussion in 'General Discussion Forum' started by Ace94, Nov 4, 2013.

    1. Ace94

      Ace94 New Member

      Joined:
      Jul 20, 2011
      Messages:
      53
      Likes Received:
      0
      Trophy Points:
      0
      If anyone is interested in typing the code, please PM me for more details.
       
    2. bambam922

      bambam922 Well-Known Member Moderator

      Joined:
      Jan 15, 2010
      Messages:
      6,071
      Likes Received:
      28
      Trophy Points:
      48
      People here are verse enough with code to help you for free. Just post your problem.
       
    3. Ace94

      Ace94 New Member

      Joined:
      Jul 20, 2011
      Messages:
      53
      Likes Received:
      0
      Trophy Points:
      0
      "?nter a triangle and calculate the sine of its maximal angle. The triangle is defined by the coordinates of its vertices. The coordinates are floating-point numbers."

      The truth is that I am falling behind class and I can't type the code... trying to get back on track, but I don't have enough time to solve this issue by myself.
       
    4. bambam922

      bambam922 Well-Known Member Moderator

      Joined:
      Jan 15, 2010
      Messages:
      6,071
      Likes Received:
      28
      Trophy Points:
      48
      We won't do your homework for you.
      Though think back to trig.
      sin(θ) = opposite / hypotenuse

      So you coordinates are floating point numbers. That all well and good.
      You need to define your three sides.
      Coordinate1 = A
      Coordinate2 = B
      Coordinate3 = C

      The distance between these points will be the length of that side.
      Remember your distance formula is sqrt((x_2-x_1)^2+(y_2-y_1)^2)

      Once you define you sides, you can find the angle by taking the inverse sin.

      So θ = sin^-1(o/h)
       
    5. Ace94

      Ace94 New Member

      Joined:
      Jul 20, 2011
      Messages:
      53
      Likes Received:
      0
      Trophy Points:
      0
      Thanks! I will try to do it later today. If anything pops up, can I ask for advice on PM?
       
    6. bambam922

      bambam922 Well-Known Member Moderator

      Joined:
      Jan 15, 2010
      Messages:
      6,071
      Likes Received:
      28
      Trophy Points:
      48
      Go for it.

      There is probably an easier way to do it via loops, but here is a starter.

      Ex.

      float pointAx = 2.6542
      float pointAy = 1.9542
      float pointBx = 1.2458
      float pointBy = 2.6542
      float pointCx = 4.2698
      float pointCy = 1.2378

      float sideAB = 0.0;
      float sideAC = 0.0;
      float sideBC = 0.0;

      sideAB = sqrt((pointBx)^2-(pointAx)^2)+((pointBy)^2-(pointAy)^2))
       

    Share This Page