44 lines
No EOL
907 B
Python
44 lines
No EOL
907 B
Python
import pyskyline
|
|
import random
|
|
|
|
terrain = pyskyline.Terrain.generate(
|
|
seed=10,
|
|
size=512,
|
|
scale=4.0,
|
|
max_altitude=40.0
|
|
)
|
|
|
|
terrain.precompute_all_skylines()
|
|
|
|
while True:
|
|
x = random.randint(0, 511)
|
|
y = random.randint(0, 511)
|
|
if terrain.is_water(x,y): break
|
|
|
|
skyline = terrain.get_skyline(x, y)
|
|
print(f"({x}, {y})")
|
|
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
plt.figure()
|
|
plt.grid(False)
|
|
plt.ylim(0,20)
|
|
plt.plot(np.arange(0,360,360/256), np.rad2deg(skyline))
|
|
plt.title('Skyline')
|
|
|
|
import cv2 as cv
|
|
|
|
cv.imwrite('elevation.jpg', terrain.grayscale())
|
|
cv.imwrite('color.jpg', terrain.rgb())
|
|
|
|
skyline = np.roll(skyline, 21) # Add heading error
|
|
# skyline += np.random.normal(0,0.01, 256) # Add random noise
|
|
|
|
res = pyskyline.MosseCorrelation.process(terrain, skyline)
|
|
|
|
plt.figure()
|
|
plt.imshow(res, cmap='hot', interpolation='nearest')
|
|
plt.title('Scoremap')
|
|
|
|
plt.show() |