70 |
return |
return |
71 |
|
|
72 |
# The angle between the basis vectors |
# The angle between the basis vectors |
73 |
angle = (.25 + angle_stddev*rnd.nextGaussian()) * math.pi |
angle = (.25 + angle_stddev*rnd.nextGaussian()) * 2 * math.pi |
74 |
angle *= 1 - 2 * rnd.nextBoolean() |
angle *= 1 - 2 * rnd.nextBoolean() |
75 |
|
|
76 |
|
|
92 |
|
|
93 |
# 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) |
94 |
self.vecs = [[ rs * math.cos(as), rt * math.cos(at)], |
self.vecs = [[ rs * math.cos(as), rt * math.cos(at)], |
95 |
[ rs * math.sin(as), rt * math.sin(at)]] |
[ rs * math.sin(as), rt * math.sin(at)]] |
96 |
|
|
97 |
def _getSTVectors(self, rnd): |
def _getSTVectors(self, rnd): |
98 |
"""Get the 2 4-component vectors that (x,y,0,1) should |
"""Get the 2 4-component vectors that (x,y,0,1) should |
151 |
a,b,c,d = chooseInts(rnd) |
a,b,c,d = chooseInts(rnd) |
152 |
# 1 / determinant |
# 1 / determinant |
153 |
f = 1.0 / (a * d - b * c) |
f = 1.0 / (a * d - b * c) |
154 |
vecs = [ [ f * self.vecs[1][1], -f*self.vecs[0][1] ], |
vecs = [ [ f * d * self.vecs[0][0] - f * b * self.vecs[0][1], -f * c * self.vecs[0][0] + f * a * self.vecs[0][1] ], |
155 |
[ -f*self.vecs[1][0], f*self.vecs[0][0] ] |
[ f * d * self.vecs[1][0] - f * b * self.vecs[1][1], -f * c * self.vecs[1][0] + f * a * self.vecs[1][1] ] ] |
156 |
] |
|
157 |
|
# Note that the 'vecs' matrix stores the parallelogram side vectors as its columns |
158 |
|
# The debug prints below show that 'vecs' correctly solves the equation |
159 |
|
if 0: |
160 |
|
print "S: ", [self.vecs[0][0], self.vecs[1][0]] |
161 |
|
print "T: ", [self.vecs[0][1], self.vecs[1][1]] |
162 |
|
print "a S' + b T':", [a*vecs[0][0]+b*vecs[0][1], a*vecs[1][0]+b*vecs[1][1]] |
163 |
|
print "c S' + d T':", [c*vecs[0][0]+d*vecs[0][1], c*vecs[1][0]+d*vecs[1][1]] |
164 |
|
print "a,b,c,d:", a,b,c,d |
165 |
|
|
166 |
return TexGenXYRepeatUnit(vecs=vecs) |
return TexGenXYRepeatUnit(vecs=vecs) |
167 |
|
|
168 |
class TexGen3DSlice: |
class TexGen3DSlice: |