# Thread: Procedural landscapes: Total n0ob needs to streamline maths code

1. ## Procedural landscapes: Total n0ob needs to streamline maths code

I have a code that generates mountain shapes for 10 different 3d maps covering an entire graph, then i delete 90 percent of each map and mix the rest into a final map with a variety of mountain shapes. Therefore processor useage is 9 times inefficent! The code can make infinite variety of basic shapes and mixes.

The graphics engine asks height information for X,Y, and the code returns Z using sine functions.

graph axes X and Y are Floats in the range -1,1.

How can make variables new_X and new_Y that are only segments of X,Y, So that i can code sin(new_X)*sin(new_Y), and it will calculate mountains only in the ranges that will be visible in the final map? for example new_X would be a segment of X in the range (-0.1,0.2) that exists on the X variable.

2. If X and Y are ints, a look-up table might speed up the sin function. Usually the tradeoff is more memory used for implementing the table, but less processing time.

As to limiting of the number of calcs to a given "zone", I don't understand your algorithm as you presented it. There's a capital Y and a small y, capital Z and small z. How about either some descriptions, or better, more descriptive variable names?

3. Thanks!

Sorry i have rewritten the explanation more clearly. the X and Y axes are Floats in the range -1 to 1, but i could convert everything to integer, which i believe is faster on x86. A sin lookup table would be awesome, i will do some reading!

I would still love to know how to make a segments of a variable where code is only processed for those segments, so that you can process different maths on each segment of a variable, rather than having to do the maths on the entire range and then delete the rest and mix the remainder, like how i am doing.