MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/Imath / createRandomMat

Function createRandomMat

src/ImathTest/testMiscMatrixAlgo.cpp:123–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123M44f
124createRandomMat (Rand48& random, V3f& trans, V3f& rot, V3f& scale)
125{
126
127 M44f M;
128 V3f t, r, s;
129 getRandTRS (random, t, r, s);
130
131 M.translate (t);
132 M.rotate (r);
133
134 // Shear M.
135 V3f h (
136 float(random.nextf (0.000001, 2.0)),
137 float(random.nextf (0.000001, 2.0)),
138 float(random.nextf (0.000001, 2.0)));
139
140 for (int j = 0; j < 3; j++)
141 if (random.nextf (0.0, 1.0) >= 0.5) h[j] *= -1;
142 M.shear (h);
143
144 M.scale (s);
145
146 //
147 // Add a small random error to the elements of M
148 //
149 for (int j = 0; j < 4; ++j)
150 for (int k = 0; k < 3; ++k)
151 M[j][k] += float(random.nextf (-1e-7, 1e-7));
152
153 V3f sh;
154 extractSHRT (M, scale, sh, rot, trans);
155
156 debug (("Scale : %f %f %f\n", s[0], s[1], s[2]));
157 debug (("Shear : %f %f %f\n", h[0], h[1], h[2]));
158 debug (("Rot : %f %f %f\n", r[0], r[1], r[2]));
159 debug (("Trans : %f %f %f\n", t[0], t[1], t[2]));
160
161 return M;
162}
163
164void
165compareMat (M44f& M, M44f& N)

Callers 2

testAddOffsetFunction · 0.85
testComputeRSMatrixFunction · 0.85

Calls 3

getRandTRSFunction · 0.85
extractSHRTFunction · 0.85
nextfMethod · 0.60

Tested by

no test coverage detected