Esempio n. 1
0
static PyObject *Euler_to_matrix(EulerObject * self)
{
	float mat[9];

	if(!BaseMath_ReadCallback(self))
		return NULL;

	eulO_to_mat3((float (*)[3])mat, self->eul, self->order);

	return newMatrixObject(mat, 3, 3 , Py_NEW, NULL);
}
Esempio n. 2
0
int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error_prefix)
{
  if (EulerObject_Check(value)) {
    if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
      return -1;
    }
    else {
      eulO_to_mat3(rmat, ((EulerObject *)value)->eul, ((EulerObject *)value)->order);
      return 0;
    }
  }
  else if (QuaternionObject_Check(value)) {
    if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
      return -1;
    }
    else {
      float tquat[4];
      normalize_qt_qt(tquat, ((QuaternionObject *)value)->quat);
      quat_to_mat3(rmat, tquat);
      return 0;
    }
  }
  else if (MatrixObject_Check(value)) {
    if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
      return -1;
    }
    else if (((MatrixObject *)value)->num_row < 3 || ((MatrixObject *)value)->num_col < 3) {
      PyErr_Format(
          PyExc_ValueError, "%.200s: matrix must have minimum 3x3 dimensions", error_prefix);
      return -1;
    }
    else {
      matrix_as_3x3(rmat, (MatrixObject *)value);
      normalize_m3(rmat);
      return 0;
    }
  }
  else {
    PyErr_Format(PyExc_TypeError,
                 "%.200s: expected a Euler, Quaternion or Matrix type, "
                 "found %.200s",
                 error_prefix,
                 Py_TYPE(value)->tp_name);
    return -1;
  }
}
Esempio n. 3
0
static PyObject *Euler_rotate(EulerObject * self, PyObject *value)
{
	float self_rmat[3][3], other_rmat[3][3], rmat[3][3];

	if(!BaseMath_ReadCallback(self))
		return NULL;

	if(mathutils_any_to_rotmat(other_rmat, value, "euler.rotate(value)") == -1)
		return NULL;

	eulO_to_mat3(self_rmat, self->eul, self->order);
	mul_m3_m3m3(rmat, self_rmat, other_rmat);

	mat3_to_compatible_eulO(self->eul, self->eul, self->order, rmat);

	(void)BaseMath_WriteCallback(self);
	Py_RETURN_NONE;
}