Created
September 29, 2017 09:43
-
-
Save OllieReynolds/a7579f11070f15f08b9766b510acb95d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private double fBoxCheap(Vec3 p, Vec3 b) { | |
return Vec3.minus(p.abs(), b).max(); | |
} | |
private double map(Vec3 p) { | |
double theta = elapsedTime * 0.001; | |
Vec2 yz = new Vec2(0.0, 0.0); | |
yz.x = (p.y * Math.cos(theta)) - (p.z * Math.sin(theta)); | |
yz.y = (p.z * Math.cos(theta)) + (p.y * Math.sin(theta)); | |
p.y = yz.x; | |
p.z = yz.y; | |
Vec2 xy = new Vec2(0.0, 0.0); | |
xy.x = (p.x * Math.cos(theta)) - (p.y * Math.sin(theta)); | |
xy.y = (p.y * Math.cos(theta)) + (p.x * Math.sin(theta)); | |
p.x = xy.x; | |
p.y = xy.y; | |
final double sz1 = 0.5; | |
final double sz2 = sz1 - 0.1; | |
final double sz3 = sz1 * 2.0; | |
final double a = fBoxCheap(p, new Vec3(sz1, sz1, sz1)); | |
final double b = fBoxCheap(p, new Vec3(sz3, sz2, sz2)); | |
final double c = fBoxCheap(p, new Vec3(sz2, sz3, sz2)); | |
final double d = fBoxCheap(p, new Vec3(sz2, sz2, sz3)); | |
return Math.max(Math.max(Math.max(a, -b), -c), -d); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment