C++ math equation

This is a discussion on C++ math equation within the C++ Programming forums, part of the General Programming Boards category; Hello guys, I got the following problem... Code: In the mid-west many farmers irrigate from a well near the center ...

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    72

    C++ math equation

    Hello guys, I got the following problem...

    Code:
    In the mid-west many farmers irrigate from a well near
    the center of a piece of land using a circular
    irrigation system. The farmer plans on farming an 
    almost square (but it is a rectangle) piece of 
    property and needs to know some answers for planning.
    
    This program is to get two measurements for a rectangular
    piece of property.  The measurements will be in feet,
    and should be identified with variables named length 
    width. The program is to calculate the area in square
    feet of the rectangle and the largest circle that could
    fit into the rectangle.
    
    The farmer wants to know the acreage of:
    
    1. the property
    2. the farmable area
    3. the non-farmable area
    I have like no idea how to put that in an equation. The rectangular piece is easy.. sidea*sideb .Then I'm gonna get the rectangular piece.
    But how do I get a equation for how many circles would fit into that rectangular piece? The non-farmable area would just be rectangular piece area - circle. I assume the circle would be the farmable area since it gets watered. And the property would be the rectangular piece.

  2. #2
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    398
    Use the equation of an ellipse
    http://en.wikipedia.org/wiki/Elliptical

    Edit: Just noticed in the problem it asks for a circle, so if you looked at the equation of the ellipse, both "a" and "b" need to be correspond with the side with the shortest length.

    So lets say your rectangle has sides 8 and 4.
    Your equation for the largest circle that would fit would be: (x^2) + (y^2) = 4
    Last edited by carrotcake1029; 03-01-2009 at 06:46 PM.

  3. #3
    Registered User
    Join Date
    Jul 2008
    Posts
    72
    Ok let's say it's (x^2)/4 + (y^2)/4 = 1.

    4 being side b. (x^2)/b + (y^2)/b = 1

    But how would that get the how many circles fit in it? I thought the bottom line would be x and the side y.
    Last edited by XodoX; 03-01-2009 at 06:05 PM.

  4. #4
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    398
    ok

    side a = 8
    side b = 4

    The largest circle can only have the diameter of the smallest side:

    The area of a circle is pi * r^2.... so

    But how would that get the how many circles fit in it? I thought the bottom line would be x and the side y.
    The directions do not ask for this. Technically if you think of it, there is an infinite amount of variate sized circles that could fit in
    Last edited by carrotcake1029; 03-01-2009 at 06:45 PM.

  5. #5
    Registered User
    Join Date
    Jul 2008
    Posts
    72
    So I do the rectangular calculation first, the the one for the circle and then I do this.
    I honestly still don't know what value will be x and y.

  6. #6
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    the diameter of the circle is equal to the smaller sides of the rectangle

  7. #7
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    398
    x and y are variables. If you plug two values into them and the equation is equal, then that point is an actual coordinate of the circle.

    This is very basic math. Not to be mean or anything but if this is beyond you, you may want to reconsider a programming class that will most likely use some algebra 1&2 / geometry examples for your programs.

    For C/C++ programming classes, the math is supposed to be basic so its not what you focus on. They are trying to get you to use what you have learned in class in order to write a program.
    Last edited by carrotcake1029; 03-01-2009 at 06:20 PM.

  8. #8
    Registered User
    Join Date
    Jul 2008
    Posts
    72
    Yes, I know now.

    It says any set of points satisfies the x and y, but that can't be in this case. At least wouldn't make any sense to me.

  9. #9
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    398
    Can you see here at what I am getting at?
    http://img514.imageshack.us/img514/3...erectangle.png

    I'm out of ideas.

    By the way I was a little off about the equation of a circle earlier. I was trying to work off the equation of an ellipse, but did it wrong.
    You would want to use x^2 + y^2 = r^2, but for your assignment, you don't need to know this.
    Last edited by carrotcake1029; 03-01-2009 at 06:44 PM.

  10. #10
    Registered User
    Join Date
    Jul 2008
    Posts
    72
    Yeah, I do know what you mean by that. I just do not know how to do the "how many circles could fit in the rectangular piece" equation.

    I can just get the circle by using the one side of the rectangular piece. After I did that it would be

    area of rectangular - area of circle = non-farmable area. The circle would be the farmable area.

  11. #11
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    398
    Yeah, I do know what you mean by that. I just do not know how to do the "how many circles could fit in the rectangular piece" equation.
    Well, I'll give you some situations.

    If A = 8 and B = 4:
    Two circles of the maximum possible diameter will fit.

    If A = 9 and B = 3:
    Three circles of the maximum possible diameter will fit.

    If A = 12 and B = 3:
    Four circles of the maximum possible diameter will fit.

    See the pattern?

  12. #12
    Registered User
    Join Date
    Jul 2008
    Posts
    72
    Quote Originally Posted by carrotcake1029 View Post
    Well, I'll give you some situations.

    If A = 8 and B = 4:
    Two circles of the maximum possible diameter will fit.

    If A = 9 and B = 3:
    Three circles of the maximum possible diameter will fit.

    If A = 12 and B = 3:
    Four circles of the maximum possible diameter will fit.

    See the pattern?
    Yes, I do. I know how this works.. but I canšt come up with an equation.
    The area of the circle is A= Pi * r^2 . With r being that one side of the rectangular piece.

    So basically jI ust the equation for how many circles fit in is what I need now.

  13. #13
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    i don't see that question in your problem statement. are you not reading it or am i?

  14. #14
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    398
    Step 1: (The property)
    Multiply the sides together

    Step 2:
    Identify the length of the shortest side of your rectangle.

    Step 3:
    Find how many times the length of the shortest side of your rectangle can fit into the length of the longest side.

    Step 4:
    The area of one circle will be:
    pi * (short length/2)^2

    Step 5: (The farmable area)
    The area of all the circles that fit into the rectangle will be:
    (step 3 answer) * (step 4 answer)

    Step 6: (The non-farmable area)
    (step 1 answer) - (step 5 answer)


    This is of course if the assignment is really asking for this, which I don't see.

  15. #15
    Registered User
    Join Date
    Jul 2008
    Posts
    72
    Yes, the largest circle. Nevermind.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 11-04-2006, 03:06 AM
  2. Converting String to Math Equation
    By draggy in forum C++ Programming
    Replies: 5
    Last Post: 07-10-2005, 06:59 PM
  3. Math Equation Program (I can't find the problem with my program!)
    By masked_blueberr in forum C Programming
    Replies: 14
    Last Post: 07-06-2005, 11:53 AM
  4. IDEA: Equation solver
    By Magos in forum Contests Board
    Replies: 2
    Last Post: 01-07-2003, 10:46 AM
  5. A math equation
    By dizolve in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 12-17-2002, 11:56 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21