115 {
116 const float a = in[0][0], b = in[0][1], c = in[0][2];
117 const float d = in[1][0], e = in[1][1], f = in[1][2];
118 const float g = in[2][0], h = in[2][1], i = in[2][2];
119 const float det = a * (e * i - f * h) - b * (d * i - f *
g) + c * (d * h - e *
g);
120
121
122
123
124
125
126
127
128
129
130
131
135
136
137
138
139
140
141
142 const float an = a / scale_a, dn = d / scale_a, gn =
g / scale_a;
143 const float bn = b / scale_b, en = e / scale_b, hn = h / scale_b;
144 const float cn = c / scale_c, fn = f / scale_c, in_ = i / scale_c;
145 const float det_normalized = an * (en * in_ - fn * hn) -
146 bn * (dn * in_ - fn * gn) +
147 cn * (dn * hn - en * gn);
149 return false;
150 }
151
152 const float inv_det = 1.0f / det;
153 out[0][0] = (e * i - f * h) * inv_det;
154 out[0][1] = (c * h - b * i) * inv_det;
155 out[0][2] = (b * f - c * e) * inv_det;
156 out[1][0] = (f *
g - d * i) * inv_det;
157 out[1][1] = (a * i - c *
g) * inv_det;
158 out[1][2] = (c * d - a * f) * inv_det;
159 out[2][0] = (d * h - e *
g) * inv_det;
160 out[2][1] = (b *
g - a * h) * inv_det;
161 out[2][2] = (a * e - b * d) * inv_det;
162 return true;
163}
constexpr float kRelativeSingularity
How small a determinant may be, relative to the matrix's own scale, before the inverse is rounding no...
float columnScale(float a, float b, float c) FL_NO_EXCEPT
Largest absolute entry of a column, which is its infinity norm.
double fabs(double value) FL_NO_EXCEPT