Results 1 to 3 of 3

Thread: Graph maths

  1. #1
    Join Date
    Jul 2012
    Rep Power

    Default Graph maths


    I've got a problem that I suppose is more about maths than Java. I'm doing the cs106a Stanford online class, and am stuck thinking about how to represent a graph on a page, where the values of y goes up as you go down the page, and the values of the data goes up in the other direction. And the value of y is variable, because the window can be resized. There's also a bottom and a top margin to the graph on the window, so the top data value doesn't match precisely to 0 and the 0 data value doesn't map precisely to getHeight().

    The max data value is 1000. So 1000 would always be at 0 + margin. And 0 data value would always be getHeight() - margin. Not sure how to go from there to calculating the point on the page for any value in between...

    Cheers, R

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Washington, DC
    Rep Power

    Default Re: Graph maths

    I really don't know what you're asking, but I would suggest getting out a piece of paper and a pencil and drawing a bunch of different scenarios until you start to see a pattern.
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  3. #3
    Join Date
    Jul 2012
    Rep Power

    Default Re: Graph maths

    Well, the pattern doesn't really change, it's as I described. lets say there's a point on the graph at 750. I'm trying to find a formula that would calculate the position on the y axis for that point. Or any point between 0 and 1000.

Similar Threads

  1. Confusion with maths game?...
    By Bimz in forum New To Java
    Replies: 8
    Last Post: 08-29-2011, 11:08 AM
  2. Help me with maths on my program!
    By Ruuhkis in forum New To Java
    Replies: 6
    Last Post: 02-17-2011, 06:27 AM
  3. Maths for programming
    By ron2794 in forum New To Java
    Replies: 3
    Last Post: 12-17-2010, 08:17 AM
  4. Maths Packages
    By Anish in forum Advanced Java
    Replies: 7
    Last Post: 11-27-2008, 06:46 AM
  5. Whats wrong with my maths???
    By soc86 in forum New To Java
    Replies: 4
    Last Post: 11-03-2008, 05:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts