diff --git a/src/Makefile b/src/Makefile
index cde6c43..3e48366 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,8 +1,8 @@
include ../common.mk
TARGET = drow-engine
-HEADERS = err.h common.h print.h filereader.h gl_draw.h vector.h half_edge.h
-OBJECTS = print.o filereader.o gl_draw.o vector.o half_edge.o half_edge_AS.o
+HEADERS = err.h common.h print.h filereader.h gl_draw.h vector.h half_edge.h bezier.h
+OBJECTS = print.o filereader.o gl_draw.o vector.o half_edge.o half_edge_AS.o bezier.o
INCS = -I.
CFLAGS += $(shell $(PKG_CONFIG) --cflags gl glu glib-2.0)
diff --git a/src/bezier.c b/src/bezier.c
new file mode 100644
index 0000000..edc08b3
--- /dev/null
+++ b/src/bezier.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2011-2014 hasufell
+ *
+ * This file is part of a hasufell project.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License only.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * @file bezier.c
+ * This file provides operations and informational functions
+ * on the bezier data type which is defined in bezier.h.
+ * @brief operations on bezier curves
+ */
+
+#include "bezier.h"
+#include "vector.h"
+
+#include
+#include
+
+
+/**
+ * Calculate a point on the bezier curve according to the
+ * bezier vertices. If section is set to 0.5 then it will
+ * return the vector to the point in the middle of the curve.
+ *
+ * @param obj the object holding the bezier vertices information
+ * @param section the section which will be applied to all
+ * lines between the bezier vertices
+ * @return the vector to the calculated point
+ */
+vector *calculate_bezier_point(bez_curv *bez, float section)
+{
+ vector vec_arr[bez->deg];
+ bez_curv new_bez;
+
+ for (uint32_t i = 0; i < bez->deg; i++) {
+ vector new_vec;
+
+ SUB_VECTORS(&(bez->vec[i + 1]), &(bez->vec[i]), &new_vec);
+ VECTOR_LEN_SCAL_MUL(&new_vec, section, &new_vec);
+ ADD_VECTORS(&new_vec, &(bez->vec[i]), &new_vec);
+
+ vec_arr[i] = new_vec;
+ }
+
+ new_bez.vec = vec_arr;
+ new_bez.deg = bez->deg - 1;
+
+ if (new_bez.deg > 0) {
+ return calculate_bezier_point(&new_bez, section);
+ } else {
+ vector *result_vector = malloc(sizeof(*result_vector));
+ *result_vector = vec_arr[0];
+ return result_vector;
+ }
+}
+
+
diff --git a/src/bezier.h b/src/bezier.h
new file mode 100644
index 0000000..ccbde1e
--- /dev/null
+++ b/src/bezier.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2011-2014 hasufell
+ *
+ * This file is part of a hasufell project.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License only.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * @file bezier.h
+ * Header for the external API of bezier.c.
+ * @brief header of bezier.c
+ */
+
+#ifndef _DROW_ENGINE_BEZIER_H
+#define _DROW_ENGINE_BEZIER_H
+
+
+#include "vector.h"
+
+#include
+
+
+typedef struct bez_curv bez_curv;
+
+
+/**
+ * Bezier Curve.
+ */
+struct bez_curv {
+ /**
+ * Array of vectors.
+ */
+ vector *vec;
+ /**
+ * Degree of the curve.
+ */
+ uint32_t deg;
+};
+
+
+vector *calculate_bezier_point(bez_curv *bez, float section);
+
+
+#endif /* _DROW_ENGINE_BEZIER_H */
diff --git a/src/gl_draw.c b/src/gl_draw.c
index ccbbb16..4774bae 100644
--- a/src/gl_draw.c
+++ b/src/gl_draw.c
@@ -24,6 +24,7 @@
* @brief OpenGL drawing
*/
+#include "bezier.h"
#include "err.h"
#include "filereader.h"
#include "gl_draw.h"
diff --git a/src/half_edge.c b/src/half_edge.c
index 99c90f0..3398e66 100644
--- a/src/half_edge.c
+++ b/src/half_edge.c
@@ -285,43 +285,6 @@ bool normalize_object(HE_obj *obj)
return true;
}
-/**
- * Calculate a point on the bezier curve according to the
- * bezier vertices. If section is set to 0.5 then it will
- * return the vector to the point in the middle of the curve.
- *
- * @param obj the object holding the bezier vertices information
- * @param section the section which will be applied to all
- * lines between the bezier vertices
- * @return the vector to the calculated point
- */
-vector *calculate_bezier_point(bez_curv *bez, float section)
-{
- vector vec_arr[bez->deg];
- bez_curv new_bez;
-
- for (uint32_t i = 0; i < bez->deg; i++) {
- vector new_vec;
-
- SUB_VECTORS(&(bez->vec[i + 1]), &(bez->vec[i]), &new_vec);
- VECTOR_LEN_SCAL_MUL(&new_vec, section, &new_vec);
- ADD_VECTORS(&new_vec, &(bez->vec[i]), &new_vec);
-
- vec_arr[i] = new_vec;
- }
-
- new_bez.vec = vec_arr;
- new_bez.deg = bez->deg - 1;
-
- if (new_bez.deg > 0) {
- return calculate_bezier_point(&new_bez, section);
- } else {
- vector *result_vector = malloc(sizeof(*result_vector));
- *result_vector = vec_arr[0];
- return result_vector;
- }
-}
-
/**
* Free the inner structures of an object.
*
diff --git a/src/half_edge.h b/src/half_edge.h
index 5d71330..390d58d 100644
--- a/src/half_edge.h
+++ b/src/half_edge.h
@@ -29,6 +29,7 @@
#define _DROW_ENGINE_HE_OPERATIONS_H
+#include "bezier.h"
#include "vector.h"
#include
@@ -108,7 +109,6 @@ typedef struct HE_vert_acc HE_vert_acc;
typedef struct HE_face HE_face;
typedef struct HE_obj HE_obj;
typedef struct color color;
-typedef struct bez_curv bez_curv;
/**
@@ -303,20 +303,6 @@ struct color {
double blue;
};
-/**
- * Bezier Curve.
- */
-struct bez_curv {
- /**
- * Array of vectors.
- */
- vector *vec;
- /**
- * Degree of the curve.
- */
- uint32_t deg;
-};
-
bool face_normal(HE_edge const * const edge,
vector *vec);
@@ -324,7 +310,6 @@ bool vec_normal(HE_vert const * const vert, vector *vec);
bool find_center(HE_obj const * const obj, vector *vec);
float get_normalized_scale_factor(HE_obj const * const obj);
bool normalize_object(HE_obj *obj);
-vector *calculate_bezier_point(bez_curv *bez, float section);
HE_obj *parse_obj(char const * const filename);
void delete_object(HE_obj *obj);