Created
December 2, 2012 13:40
-
-
Save saward/4188727 to your computer and use it in GitHub Desktop.
Ruby perlin simplex issue
This file contains hidden or 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
require 'perlin' | |
perl = Perlin::Generator.new 226, 0.25, 2 | |
x = 1.1867 | |
y = 12.90625044 | |
mod = 0.0000004 | |
p = perl[x, y] | |
right = perl[x + mod, y] | |
down = perl[x, y + mod] | |
left = perl[x - mod, y] | |
up = perl[x, y - mod] | |
puts "player height: " + p.to_s | |
puts "right: " + right.to_s + ", diff: " + ((p - right)*100).to_s | |
puts "down: " + down.to_s + ", diff: " + ((p - down)*100).to_s | |
puts "left: " + left.to_s + ", diff: " + ((p - left)*100).to_s | |
puts "up: " + up.to_s + ", diff: " + ((p - up)*100).to_s | |
# Output: | |
# player height: 0.4471040368080139 | |
# right: 0.447103887796402, diff: 1.4901161193847656e-05 | |
# down: 0.36923521757125854, diff: 7.786881923675537 | |
# left: 0.4471041262149811, diff: -8.940696716308594e-06 | |
# up: 0.4471040368080139, diff: 0.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment