terraScript random is no more

This commit is contained in:
Zoë
2022-08-19 23:18:42 -05:00
parent e658a5d917
commit 5d5408e142
22 changed files with 84 additions and 176 deletions

View File

@@ -9,11 +9,12 @@ package com.dfsek.terra.api.structure;
import java.util.random.RandomGenerator;
import com.dfsek.terra.api.noise.NoiseSampler;
import com.dfsek.terra.api.util.Rotation;
import com.dfsek.terra.api.util.vector.Vector3Int;
import com.dfsek.terra.api.world.WritableWorld;
public interface Structure {
boolean generate(Vector3Int location, WritableWorld world, RandomGenerator random, Rotation rotation);
boolean generate(Vector3Int location, WritableWorld world, Rotation rotation, Long Seed);
}

View File

@@ -173,4 +173,21 @@ public final class MathUtil {
return mu + sigma * val;
}
/**
* 1D Linear interpolation between 2 points 1 unit apart.
*
* @param t - Distance from v0. Total distance between v0 and v1 is 1 unit.
* @param v0 - Value at v0.
* @param v1 - Value at v1.
*
* @return double - The interpolated value.
*/
public static double lerp(double t, double v0, double v1) {
return v0 + t * (v1 - v0);
}
public static double inverseLerp(double t, double v0, double v1) {
return (t - v0) / (v1 - v0);
}
}