Пример #1
0
void BodySW::_update_transform_dependant() {

	center_of_mass = get_transform().basis.xform(center_of_mass_local);
	principal_inertia_axes = get_transform().basis * principal_inertia_axes_local;

	// update inertia tensor
	Basis tb = principal_inertia_axes;
	Basis tbt = tb.transposed();
	tb.scale(_inv_inertia);
	_inv_inertia_tensor = tb * tbt;
}
Пример #2
0
Vector3 Basis::get_rotation() const {
	// Assumes that the matrix can be decomposed into a proper rotation and scaling matrix as M = R.S,
	// and returns the Euler angles corresponding to the rotation part, complementing get_scale().
	// See the comment in get_scale() for further information.
	Basis m = orthonormalized();
	real_t det = m.determinant();
	if (det < 0) {
		// Ensure that the determinant is 1, such that result is a proper rotation matrix which can be represented by Euler angles.
		m.scale(Vector3(-1,-1,-1));
	}

	return m.get_euler();
}
Пример #3
0
Basis Basis::scaled( const Vector3& p_scale ) const {

	Basis m = *this;
	m.scale(p_scale);
	return m;
}