On Thu, Jun 14, 2007 at 11:54:59AM -0600, Jeremy Sandberg wrote:
> I have this graph:
> http://ilmbwww.gov.bc.ca/risc/pubs/teecolo/fmdte/images/soil40.jpg And
> what I want to do is make a function out of it...something like this
> 
>       String soilTexture(int percentClay, int percentSand) {
>               //do the magic
>               return String from wherever the point falls on the graph
>       }
> 
> I was thinking of doing a 2D array but I don't really want to enter 500
> values plus there is a huge chance of error from that.

I'm confused what you mean when you say "500 values."  Also, does the
site provide the data in any other format?  It really seems like there
should be something better.

Finally, you could try parameterizing all of the lines by hand and doing
code like:

if percent_clay > 60:
    return 'HC'
elif percent_clay > 40 and percent_sand < 45:
    if percent_clay - 40 - ((40 - 60) / (20 - 0)) * (percent_sand - 20) < 0:
        return 'SiC'
    else:
        return 'C'
...

which uses the form for a line:

y - y_0 - m(x - x_0) = 0


It's a bit messy, and I might try to find something else first.

-- 
Andrew McNabb
http://www.mcnabbs.org/andrew/
PGP Fingerprint: 8A17 B57C 6879 1863 DE55  8012 AB4D 6098 8826 6868

Attachment: pgpaC9A3iliIS.pgp
Description: PGP signature

--------------------
BYU Unix Users Group 
http://uug.byu.edu/ 

The opinions expressed in this message are the responsibility of their
author.  They are not endorsed by BYU, the BYU CS Department or BYU-UUG. 
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to