Ice Starfield biome
This commit is contained in:
parent
858a7c8378
commit
19c7b37582
16 changed files with 260 additions and 0 deletions
|
@ -2,11 +2,14 @@ package ru.betterend.util;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
|
||||
public class MHelper {
|
||||
public static final float PI2 = (float) (Math.PI * 2);
|
||||
private static final int ALPHA = 255 << 24;
|
||||
public static final Random RANDOM = new Random();
|
||||
private static final float RAD_TO_DEG = 57.295779513082320876798154814105F;
|
||||
public static final float PHI = (float) (Math.PI * (3 - Math.sqrt(5)));
|
||||
|
||||
public static int color(int r, int g, int b) {
|
||||
return ALPHA | (r << 16) | (g << 8) | b;
|
||||
|
@ -247,4 +250,32 @@ public class MHelper {
|
|||
public static final float radiandToDegrees(float value) {
|
||||
return value * RAD_TO_DEG;
|
||||
}
|
||||
|
||||
public static Vector3f cross(Vector3f vec1, Vector3f vec2)
|
||||
{
|
||||
float cx = vec1.getY() * vec2.getZ() - vec1.getZ() * vec2.getY();
|
||||
float cy = vec1.getZ() * vec2.getX() - vec1.getX() * vec2.getZ();
|
||||
float cz = vec1.getX() * vec2.getY() - vec1.getY() * vec2.getX();
|
||||
return new Vector3f(cx, cy, cz);
|
||||
}
|
||||
|
||||
public static Vector3f normalize(Vector3f vec) {
|
||||
float length = lengthSqr(vec.getX(), vec.getY(), vec.getZ());
|
||||
if (length > 0) {
|
||||
length = (float) Math.sqrt(length);
|
||||
float x = vec.getX() / length;
|
||||
float y = vec.getY() / length;
|
||||
float z = vec.getZ() / length;
|
||||
vec.set(x, y, z);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
public static float angle(Vector3f vec1, Vector3f vec2)
|
||||
{
|
||||
float dot = vec1.getX() * vec2.getX() + vec1.getY() * vec2.getY() + vec1.getZ() * vec2.getZ();
|
||||
float length1 = lengthSqr(vec1.getX(), vec1.getY(), vec1.getZ());
|
||||
float length2 = lengthSqr(vec2.getX(), vec2.getY(), vec2.getZ());
|
||||
return (float) Math.acos(dot / Math.sqrt(length1 * length2));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue