Module: CGLM::Euler

Defined in:
ext/cglm/rb_cglm.c

Constant Summary collapse

XYZ =
INT2NUM(GLM_EULER_XYZ)
XZY =
INT2NUM(GLM_EULER_XZY)
YZX =
INT2NUM(GLM_EULER_YZX)
YXZ =
INT2NUM(GLM_EULER_YXZ)
ZXY =
INT2NUM(GLM_EULER_ZXY)
ZYX =
INT2NUM(GLM_EULER_ZYX)

Class Method Summary collapse

Class Method Details

.angles(mat4[, dest]) ⇒ new Vec3

Extracts euler angles (in radians) using xyz order.

Returns:



7
8
9
10
11
12
13
# File 'ext/cglm/rb_cglm_euler.c', line 7

VALUE rb_cglm_euler_angles(int argc, VALUE *argv, VALUE self) {
  VALUE m, dest;
  rb_scan_args(argc, argv, "11", &m, &dest);
  if (NIL_P(dest)) dest = VEC3_NEW(ALLOC_VEC3);
  glm_euler_angles(VAL2MAT4(m), VAL2VEC3(dest));
  return dest;
}

.by_order(axis, angles[, dest]) ⇒ new Mat4

Builds a rotation matrix from the specified angles, in the specified order, which can be one of the constants from the Euler module, or computed using

order. angles must be a Vec3 specifying the X, Y and Z angles (in that

order).

Returns:



100
101
102
103
104
105
106
# File 'ext/cglm/rb_cglm_euler.c', line 100

VALUE rb_cglm_euler_by_order(int argc, VALUE *argv, VALUE self) {
  VALUE angles, axis, dest;
  rb_scan_args(argc, argv, "21", &axis, &angles, &dest);
  if (NIL_P(dest)) dest = MAT4_NEW(ALLOC_MAT4);
  glm_euler_by_order(VAL2VEC3(angles), NUM2INT(axis), VAL2MAT4(dest));
  return dest;
}

.order(axis) ⇒ Numeric

Returns a numeric handle representing the specified axis order. axis is an array containing axis indices (0 for X, 1 for Y, 2 for Z).

Example:

order([0, 2, 1]) #=> first X, then Z, then Y

Returns:



118
119
120
121
122
123
# File 'ext/cglm/rb_cglm_euler.c', line 118

VALUE rb_cglm_euler_order(VALUE klass, VALUE order_ary) {
  int order[3] = { NUM2INT(rb_ary_entry(order_ary, 0)),
                   NUM2INT(rb_ary_entry(order_ary, 1)),
                   NUM2INT(rb_ary_entry(order_ary, 2)) };
  return INT2NUM(glm_euler_order(order));
}

.xyz(angles[, dest]) ⇒ new Mat4

Builds a rotation matrix from the specified angles, in xyz order. angles must be a Vec3 specifying the X, Y and Z angles (in that order).

Returns:



20
21
22
23
24
25
26
# File 'ext/cglm/rb_cglm_euler.c', line 20

VALUE rb_cglm_euler_xyz(int argc, VALUE *argv, VALUE self) {
  VALUE angles, dest;
  rb_scan_args(argc, argv, "11", &angles, &dest);
  if (NIL_P(dest)) dest = MAT4_NEW(ALLOC_MAT4);
  glm_euler_xyz(VAL2VEC3(angles), VAL2MAT4(dest));
  return dest;
}

.xzy(angles[, dest]) ⇒ new Mat4

Builds a rotation matrix from the specified angles, in xzy order. angles must be a Vec3 specifying the X, Y and Z angles (in that order).

Returns:



59
60
61
62
63
64
65
# File 'ext/cglm/rb_cglm_euler.c', line 59

VALUE rb_cglm_euler_xzy(int argc, VALUE *argv, VALUE self) {
  VALUE angles, dest;
  rb_scan_args(argc, argv, "11", &angles, &dest);
  if (NIL_P(dest)) dest = MAT4_NEW(ALLOC_MAT4);
  glm_euler_xzy(VAL2VEC3(angles), VAL2MAT4(dest));
  return dest;
}

.yxz(angles[, dest]) ⇒ new Mat4

Builds a rotation matrix from the specified angles, in yxz order. angles must be a Vec3 specifying the X, Y and Z angles (in that order).

Returns:



85
86
87
88
89
90
91
# File 'ext/cglm/rb_cglm_euler.c', line 85

VALUE rb_cglm_euler_yxz(int argc, VALUE *argv, VALUE self) {
  VALUE angles, dest;
  rb_scan_args(argc, argv, "11", &angles, &dest);
  if (NIL_P(dest)) dest = MAT4_NEW(ALLOC_MAT4);
  glm_euler_yxz(VAL2VEC3(angles), VAL2MAT4(dest));
  return dest;
}

.yzx(angles[, dest]) ⇒ new Mat4

Builds a rotation matrix from the specified angles, in yzx order. angles must be a Vec3 specifying the X, Y and Z angles (in that order).

Returns:



72
73
74
75
76
77
78
# File 'ext/cglm/rb_cglm_euler.c', line 72

VALUE rb_cglm_euler_yzx(int argc, VALUE *argv, VALUE self) {
  VALUE angles, dest;
  rb_scan_args(argc, argv, "11", &angles, &dest);
  if (NIL_P(dest)) dest = MAT4_NEW(ALLOC_MAT4);
  glm_euler_yzx(VAL2VEC3(angles), VAL2MAT4(dest));
  return dest;
}

.zxy(angles[, dest]) ⇒ new Mat4

Builds a rotation matrix from the specified angles, in zxy order. angles must be a Vec3 specifying the X, Y and Z angles (in that order).

Returns:



46
47
48
49
50
51
52
# File 'ext/cglm/rb_cglm_euler.c', line 46

VALUE rb_cglm_euler_zxy(int argc, VALUE *argv, VALUE self) {
  VALUE angles, dest;
  rb_scan_args(argc, argv, "11", &angles, &dest);
  if (NIL_P(dest)) dest = MAT4_NEW(ALLOC_MAT4);
  glm_euler_zxy(VAL2VEC3(angles), VAL2MAT4(dest));
  return dest;
}

.zyx(angles[, dest]) ⇒ new Mat4

Builds a rotation matrix from the specified angles, in zyx order. angles must be a Vec3 specifying the X, Y and Z angles (in that order).

Returns:



33
34
35
36
37
38
39
# File 'ext/cglm/rb_cglm_euler.c', line 33

VALUE rb_cglm_euler_zyx(int argc, VALUE *argv, VALUE self) {
  VALUE angles, dest;
  rb_scan_args(argc, argv, "11", &angles, &dest);
  if (NIL_P(dest)) dest = MAT4_NEW(ALLOC_MAT4);
  glm_euler_zyx(VAL2VEC3(angles), VAL2MAT4(dest));
  return dest;
}