File: quaternion_trigonometric.h

package info (click to toggle)
python-pyglm 2.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,008 kB
  • sloc: cpp: 53,029; python: 3,683; makefile: 7
file content (45 lines) | stat: -rw-r--r-- 1,456 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once

#include "../../compiler_setup.h"

#include "../../types/all.h"

#include "../../internal_functions/all.h"

#include "../function_generator_macros.h"

PyGLM_MAKE_GLM_FUNC_Q(angle)
PyGLM_MAKE_GLM_FUNC_Q(axis)

static PyObject*
angleAxis_(PyObject*, PyObject* args) {
	PyObject* arg1, * arg2;
	PyGLM_Arg_Unpack_2O(args, "angleAxis", arg1, arg2);
	PyGLM_PTI_Init1(arg2, PyGLM_T_VEC | PyGLM_SHAPE_3 | PyGLM_DT_FD);
	if (PyGLM_Number_Check(arg1) && PyGLM_Vec_PTI_Check1(3, float, arg2)) {
		return pack(glm::angleAxis(PyGLM_Number_FromPyObject<float>(arg1), PyGLM_Vec_PTI_Get1(3, float, arg2)));
	}
	if (PyGLM_Number_Check(arg1) && PyGLM_Vec_PTI_Check1(3, double, arg2)) {
		return pack(glm::angleAxis(PyGLM_Number_FromPyObject<double>(arg1), PyGLM_Vec_PTI_Get1(3, double, arg2)));
	}
	PyErr_SetString(PyExc_TypeError, "invalid argument type(s) for angleAxis()");
	return NULL;
}

PyDoc_STRVAR(angle_docstr,
	"angle(x: quat) -> float\n"
	"	Returns the quaternion rotation angle."
);
PyDoc_STRVAR(angleAxis_docstr,
	"angleAxis(angle: float, axis: vec3) -> quat\n"
	"	Build a quaternion from an angle and a normalized axis."
);
PyDoc_STRVAR(axis_docstr,
	"axis(x: quat) -> vec3\n"
	"	Returns the `q` rotation axis."
);

#define QUATERNION_TRIGONOMETRIC_METHODS \
{ "angle", (PyCFunction)angle_, METH_O, angle_docstr }, \
{ "axis", (PyCFunction)axis_, METH_O, axis_docstr }, \
{ "angleAxis", (PyCFunction)angleAxis_, METH_VARARGS, angleAxis_docstr }