Skip to content

Commit

Permalink
Bunch more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaž Hrastnik committed Jul 14, 2016
1 parent dd457c7 commit dfca853
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/archSeer/yard-mruby
revision: 231298ba349202b1a007adb016cf506285421c1c
revision: e1112e6ee2ecae4ffcd8cb9f00ecad03b43a1803
specs:
yard-mruby (0.2.2)
yard
Expand Down
46 changes: 43 additions & 3 deletions modules/system/src/mrb_vector3.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ vector3_dot(mrb_state *mrb, mrb_value self)
return mrb_float_value(mrb, glm::dot(get_vector3_value(mrb, self), *other));
}

/* Returns the cross product of self and other.
* @param [Vector3] other
* @return [Vector3]
*/
static mrb_value
vector3_cross(mrb_state *mrb, mrb_value self)
{
Expand All @@ -276,16 +280,22 @@ vector3_cross(mrb_state *mrb, mrb_value self)
return dest_vec;
}

// @return [Float]
/* Returns the distance betwwen self and other, i.e., length(p0 - p1).
* @param [Vector3] other
* @return [Float]
*/
static mrb_value
vector3_distance(mrb_state *mrb, mrb_value self)
{
Moon::Vector3 *other;
mrb_get_args(mrb, "d", &other, &vector3_data_type);
return mrb_float_value(mrb, glm::distance(get_vector3_value(mrb, self), *other));
}

// @return [Vector3]
/*
* @param [Vector3] other
* @param [Float] angle
* @return [Vector3]
*/
static mrb_value
vector3_rotate(mrb_state *mrb, mrb_value self)
{
Expand All @@ -295,6 +305,10 @@ vector3_rotate(mrb_state *mrb, mrb_value self)
return mmrb_vector3_value(mrb, glm::rotate(*mmrb_vector3_ptr(mrb, self), (float)angle, *other));
}

/* Rotate the vector around the x axis.
* @param [Float] angle
* @return [Vector3]
*/
static mrb_value
vector3_rotate_x(mrb_state *mrb, mrb_value self)
{
Expand All @@ -303,6 +317,10 @@ vector3_rotate_x(mrb_state *mrb, mrb_value self)
return mmrb_vector3_value(mrb, glm::rotateX(*mmrb_vector3_ptr(mrb, self), (float)angle));
}

/* Rotate the vector around the y axis.
* @param [Float] angle
* @return [Vector3]
*/
static mrb_value
vector3_rotate_y(mrb_state *mrb, mrb_value self)
{
Expand All @@ -311,6 +329,10 @@ vector3_rotate_y(mrb_state *mrb, mrb_value self)
return mmrb_vector3_value(mrb, glm::rotateY(*mmrb_vector3_ptr(mrb, self), (float)angle));
}

/* Rotate the vector around the z axis.
* @param [Float] angle
* @return [Vector3]
*/
static mrb_value
vector3_rotate_z(mrb_state *mrb, mrb_value self)
{
Expand All @@ -319,6 +341,14 @@ vector3_rotate_z(mrb_state *mrb, mrb_value self)
return mmrb_vector3_value(mrb, glm::rotateZ(*mmrb_vector3_ptr(mrb, self), (float)angle));
}

/* Linear interpolation of two quaternions.
*
* The interpolation is oriented.
*
* @param [Vector3] other quaternion
* @param [Float] delta Interpolation factor. The interpolation is defined in the range [0, 1].
* @return [Vector3]
*/
static mrb_value
vector3_lerp(mrb_state *mrb, mrb_value self)
{
Expand All @@ -328,6 +358,16 @@ vector3_lerp(mrb_state *mrb, mrb_value self)
return mmrb_vector3_value(mrb, glm::lerp(*mmrb_vector3_ptr(mrb, self), *other, (float)delta));
}

/* Spherical linear interpolation of two quaternions.
*
* Returns the slurp interpolation between two quaternions.
*
* The interpolation always take the short path and the rotation is performed at constant speed.
*
* @param [Vector3] other quaternion
* @param [Float] delta Interpolation factor. The interpolation is defined beyond the range [0, 1].
* @return [Vector3]
*/
static mrb_value
vector3_slerp(mrb_state *mrb, mrb_value self)
{
Expand Down
4 changes: 4 additions & 0 deletions modules/system/src/mrb_vector4.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ vector4_xor(mrb_state *mrb, mrb_value self)
m_vector_int_operator(^);
}

/* Returns the dot product of self and other, i.e., result = self * other.
* @param [Vector4] other
* @return [Float]
*/
static mrb_value
vector4_dot(mrb_state *mrb, mrb_value self)
{
Expand Down

0 comments on commit dfca853

Please sign in to comment.