Thread: Newbie: Stuck on some Math

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    8

    Newbie: Stuck on some Math

    Hi All

    I'm new to the forum and new to C. I have an assignment that I am having trouble with.

    First off what I need to do is re-organize this formula to find θ.

    http://img395.imageshack.us/img395/7...tioncy4.th.jpg

    Initially I had to write code to find "d". I managed that by breaking the formula into three sections (ie square root, division, and sine squared).

    I am finding it very difficult to re-organize this formula and have written more than two pages of twisting and changing but cannot get it. Maybe it is not possible and I will need to break it down into subsections without changing it around??

    Anyway, any and all help will be much appreciated.

    Thanks

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So, the formula is, rewritten as C-ish:
    Code:
    d = (v * cos(B) / g) * (sin(B) + sqrt(v * v * (sin(B) * sin(B) - 2 * g * h))
    And you want to transform that into something that gives B = ....

    That is beyond me - I'm just making sure that we're answering the right question first of all (one could easily spend quite a bit on rewriting the formula in different ways, and it's good to be sure that it's the RIGHT form first).

    --
    Mats
    Last edited by matsp; 09-01-2008 at 06:37 AM.
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    8
    Yes, that's the first part.

    I am fairly certain that it is necessary to change the formula in order to find θ.

    Specifically I need to: "Extend your program to take three additional inputs v, h and d, and produce θ as output."

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    And what does that formula represent (does it have a name?) - it would possibly be googleable if you have something to actually search for. But sin, cos, θ and square root are far too common on the Web to make it searchable (and of course it may not use θ).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Sep 2008
    Posts
    8
    Well it's nothing common. It is the distance (d) traveled by a cannonball fired at velocity (v) at angle (θ) landing at a height (h).

    I have googled as much as possible.

  6. #6
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by filicudi View Post
    Well it's nothing common. It is the distance (d) traveled by a cannonball fired at velocity (v) at angle (θ) landing at a height (h).
    Well, nothing common nowadays. I bet in medieval times that formula was all the rage.

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Ah, got it: It's a projectile trajectory calculation, right?

    Note that the theta calculation would lead to a square equation - you get two different numerical answers (e.g. 30/60 degrees).

    Edit: took too long to post!

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Registered User
    Join Date
    Sep 2008
    Posts
    8
    Yes I think it would.

    So can you or anyone help me out by switching it around (or hint, how to).

    Many Thanks!

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You need to improve your google skills:
    http://en.wikipedia.org/wiki/Trajectory

    Look for "angle of elevation", and it gives the formula you need.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #10
    Registered User
    Join Date
    Sep 2008
    Posts
    8
    Thank you very much and I guess I do have to improve my google skills!

    A resulting question though, to calculate sin^-1(θ) is there a math.h command or do I use 1/sinθ?

    Is that the same thing?

  11. #11
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    that would be the asin() function - there is also acos, atan.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  12. #12
    Registered User
    Join Date
    Sep 2008
    Posts
    8


    I just realised that is not enough.

    My formula for the angle of elevation must take into account input (h) which is the height at which the cannonball stops. It is not continuing to the same level of the cannon.

  13. #13
    Registered User Dogmasur's Avatar
    Join Date
    Jul 2008
    Posts
    72
    Quote Originally Posted by matsp View Post
    Ah, got it: It's a projectile trajectory calculation, right?

    Note that the theta calculation would lead to a square equation - you get two different numerical answers (e.g. 30/60 degrees).

    Edit: took too long to post!

    --
    Mats
    Thats because one is considering a direct shot fired and the other angle is for a curved shot ( ie a mortar round's path of travel ). I would think for this problem you want the second, since a cannonball would travel as such, unless the distance was so minute that the shot didn't have time to begin its descent as gravity began to drag the ball down and the velocity of the shot slowed from friction, causing it to lose its ability to continue driving upward. Of course, your teacher may be treating this problem as a simple vacuum shot where neither gravity nor friction would come into play.

    EDIT: whoops, sorry Mats...I didn't see your googled link which describes this much better than I could.
    "The art of living is more like wrestling than dancing." - Marcus Aurelius

  14. #14
    Registered User
    Join Date
    Sep 2008
    Posts
    8

  15. #15
    Registered User Dogmasur's Avatar
    Join Date
    Jul 2008
    Posts
    72
    Does this help:

    http://en.wikipedia.org/wiki/Traject...le#Height_at_x

    Look for Angle theta required to hit coordinate ( x,y)
    "The art of living is more like wrestling than dancing." - Marcus Aurelius

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie Help. I can't use pow and call the math library.
    By BSmith4740 in forum C Programming
    Replies: 10
    Last Post: 06-10-2008, 07:22 PM
  2. how to use operator+() in this code?
    By barlas in forum C++ Programming
    Replies: 10
    Last Post: 07-09-2005, 07:22 PM
  3. Basic Math Problem. Undefined Math Functions
    By gsoft in forum C Programming
    Replies: 1
    Last Post: 12-28-2004, 03:14 AM
  4. toughest math course
    By axon in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 10-28-2003, 10:06 PM
  5. Newbie - file i/o - I'm stuck
    By djacko in forum C++ Programming
    Replies: 1
    Last Post: 02-22-2002, 09:56 AM

Tags for this Thread