62 |
""" |
""" |
63 |
def __init__(self, rnd=None, |
def __init__(self, rnd=None, |
64 |
vecs = None, |
vecs = None, |
65 |
|
scale = .3, |
66 |
|
scale_log_stddev = 0.4, |
67 |
angle_stddev = .065, |
angle_stddev = .065, |
|
avg_length_mean = .3, |
|
|
avg_length_stddev = .06, |
|
68 |
lendiff_mean = 0, |
lendiff_mean = 0, |
69 |
lendiff_stddev = .1): |
lendiff_stddev = .1): |
70 |
|
|
76 |
angle = (.25 + angle_stddev*rnd.nextGaussian()) * 2 * math.pi |
angle = (.25 + angle_stddev*rnd.nextGaussian()) * 2 * math.pi |
77 |
angle *= 1 - 2 * rnd.nextBoolean() |
angle *= 1 - 2 * rnd.nextBoolean() |
78 |
|
|
|
|
|
79 |
# The angle of the first basis vector |
# The angle of the first basis vector |
80 |
as = rnd.nextDouble() * 2 * math.pi |
as = rnd.nextDouble() * 2 * math.pi |
81 |
# And the angle of the second basis vector |
# And the angle of the second basis vector |
82 |
at = as + angle |
at = as + angle |
83 |
|
|
84 |
|
# Logarightm of the random scale factor |
85 |
# The (geometric) average of the basis vector lengths |
m0 = scale_log_stddev * rnd.nextGaussian() |
|
r = avg_length_mean + avg_length_stddev*rnd.nextGaussian() |
|
86 |
|
|
87 |
# The difference between basis vector lengths |
# The difference between basis vector lengths |
88 |
m = lendiff_mean + lendiff_stddev * rnd.nextGaussian() |
m = lendiff_mean + lendiff_stddev * rnd.nextGaussian() |
89 |
|
|
90 |
# The basis vector lengths |
# The basis vector lengths |
91 |
rs = r * math.exp(m) |
rs = scale * math.exp(m0 + m) |
92 |
rt = r * math.exp(-m) |
rt = scale * math.exp(m0 - m) |
93 |
|
|
94 |
# The vectors that give x and y when dotted with (s, t, 0, 1) |
# The vectors that give x and y when dotted with (s, t, 0, 1) |
95 |
self.vecs = [[ rs * math.cos(as), rt * math.cos(at)], |
self.vecs = [[ rs * math.cos(as), rt * math.cos(at)], |