static PyObject *Euler_rotate_axis(EulerObject *self, PyObject *args)
{
	float angle = 0.0f;
	int axis; /* actually a character */

	if (!PyArg_ParseTuple(args, "Cf:rotate_axis", &axis, &angle)) {
		PyErr_SetString(PyExc_TypeError,
		                "Euler.rotate_axis(): "
		                "expected an axis 'X', 'Y', 'Z' and an angle (float)");
		return NULL;
	}

	if (!(ELEM3(axis, 'X', 'Y', 'Z'))) {
		PyErr_SetString(PyExc_ValueError,
		                "Euler.rotate_axis(): "
		                "expected axis to be 'X', 'Y' or 'Z'");
		return NULL;
	}

	if (BaseMath_ReadCallback(self) == -1)
		return NULL;


	rotate_eulO(self->eul, self->order, (char)axis, angle);

	(void)BaseMath_WriteCallback(self);

	Py_RETURN_NONE;
}
Exemple #2
0
static PyObject *Euler_rotate_axis(EulerObject * self, PyObject *args)
{
	float angle = 0.0f;
	const char *axis;

	if(!PyArg_ParseTuple(args, "sf:rotate", &axis, &angle)){
		PyErr_SetString(PyExc_TypeError,
		                "euler.rotate(): "
		                "expected angle (float) and axis (x, y, z)");
		return NULL;
	}
	if(!(ELEM3(*axis, 'X', 'Y', 'Z') && axis[1]=='\0')){
		PyErr_SetString(PyExc_ValueError, "euler.rotate(): "
		                "expected axis to be 'X', 'Y' or 'Z'");
		return NULL;
	}

	if(BaseMath_ReadCallback(self) == -1)
		return NULL;


	rotate_eulO(self->eul, self->order, *axis, angle);

	(void)BaseMath_WriteCallback(self);

	Py_RETURN_NONE;
}