# Limit the max derivate of 1D Perlin Noise

This topic is 2377 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've already wrote the code to produce a "cavern" like the one attached using 1 dimensional perlin noise.
I'll have an object fly through the tunnel, and this object has a maximum velocity along the Y axis.
I want to grant the possibility to travel all the tunnel, but i need to limit the derivate of both the upped and lower part of the cave to a specific maximum.
How can i do this?

Here the code i use to generate the noise

 public class PerlinNoise { private static final int X_NOISE_GEN = 1619; private static final int SEED_NOISE_GEN = 1013; private double mPersistence = 1/4; private int mOctaves = 6; private int mSeed; public PerlinNoise() { mSeed = (int) System.currentTimeMillis(); } PerlinNoise(double persistence, int octaves, int seed) { mPersistence = persistence; mOctaves = octaves; mSeed = seed; } private double IntNoise_1D(int x) { int n = (X_NOISE_GEN * x + SEED_NOISE_GEN * mSeed )& 0x7fffffff; n = (n<<13) ^ n; return ( 1.0 - ( (n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0); } private double SmoothedNoise_1D(double x) { return IntNoise_1D((int) x)/2 + IntNoise_1D((int) (x-1))/4 + IntNoise_1D((int) (x+1))/4; } private double InterpolatedNoise_1D(double x) { int integer_X = (int) x; double fractional_X = x - integer_X; double v1 = SmoothedNoise_1D(integer_X); double v2 = SmoothedNoise_1D(integer_X + 1); return linearInterp(v1 , v2 , SCurve5(fractional_X)); } public double Noise_1D(float x) { double total = 0; for(int i = 0; i< mOctaves - 1; i++) { int frequency = (int) Math.pow(2, i); double amplitude = (int) Math.pow(mPersistence, i); total = total + InterpolatedNoise_1D(x * frequency) * amplitude; } return total; } private static double linearInterp (double n0, double n1, double a) { return (((1.0 - a) * n0) + (a * n1)); } private static double SCurve5 (double a) { double a3 = a * a * a; double a4 = a3 * a; double a5 = a4 * a; return (6.0 * a5) - (15.0 * a4) + (10.0 * a3); } } 

1. 1
Rutin
26
2. 2
3. 3
4. 4
5. 5

• 9
• 13
• 19
• 14
• 9
• ### Forum Statistics

• Total Topics
632940
• Total Posts
3009329
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!