@@ -94,6 +94,18 @@ Basis Basis::orthonormalized() const {
94
94
return c;
95
95
}
96
96
97
+ void Basis::orthogonalize () {
98
+ Vector3 scl = get_scale ();
99
+ orthonormalize ();
100
+ scale_local (scl);
101
+ }
102
+
103
+ Basis Basis::orthogonalized () const {
104
+ Basis c = *this ;
105
+ c.orthogonalize ();
106
+ return c;
107
+ }
108
+
97
109
bool Basis::is_orthogonal () const {
98
110
Basis identity;
99
111
Basis m = (*this ) * transposed ();
@@ -237,6 +249,24 @@ void Basis::scale_local(const Vector3 &p_scale) {
237
249
*this = scaled_local (p_scale);
238
250
}
239
251
252
+ void Basis::scale_orthogonal (const Vector3 &p_scale) {
253
+ *this = scaled_orthogonal (p_scale);
254
+ }
255
+
256
+ Basis Basis::scaled_orthogonal (const Vector3 &p_scale) const {
257
+ Basis m = *this ;
258
+ Vector3 s = Vector3 (-1 , -1 , -1 ) + p_scale;
259
+ Vector3 dots;
260
+ Basis b;
261
+ for (int i = 0 ; i < 3 ; i++) {
262
+ for (int j = 0 ; j < 3 ; j++) {
263
+ dots[j] += s[i] * abs (m.get_axis (i).normalized ().dot (b.get_axis (j)));
264
+ }
265
+ }
266
+ m.scale_local (Vector3 (1 , 1 , 1 ) + dots);
267
+ return m;
268
+ }
269
+
240
270
float Basis::get_uniform_scale () const {
241
271
return (elements[0 ].length () + elements[1 ].length () + elements[2 ].length ()) / 3.0 ;
242
272
}
@@ -931,6 +961,15 @@ void Basis::_set_diagonal(const Vector3 &p_diag) {
931
961
elements[2 ][2 ] = p_diag.z ;
932
962
}
933
963
964
+ Basis Basis::lerp (const Basis &p_to, const real_t &p_weight) const {
965
+ Basis b;
966
+ b.elements [0 ] = elements[0 ].lerp (p_to.elements [0 ], p_weight);
967
+ b.elements [1 ] = elements[1 ].lerp (p_to.elements [1 ], p_weight);
968
+ b.elements [2 ] = elements[2 ].lerp (p_to.elements [2 ], p_weight);
969
+
970
+ return b;
971
+ }
972
+
934
973
Basis Basis::slerp (const Basis &p_to, const real_t &p_weight) const {
935
974
// consider scale
936
975
Quaternion from (*this );
0 commit comments