commit e3e1b6f775c011a498afa32e2a401cca3341c3e3
parent 1d8c879137b59eeece12d58a26eeb56fefef2f80
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 28 Mar 2016 10:22:39 +0200
First draft of the helicoid mesh generation routine
Diffstat:
3 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/src/schiff.c b/src/schiff.c
@@ -270,6 +270,7 @@ error:
/*******************************************************************************
* Entry point
******************************************************************************/
+#include "schiff_mesh.h"
int
main(int argc, char** argv)
{
@@ -277,6 +278,9 @@ main(int argc, char** argv)
int err = 0;
res_T res;
+ schiff_mesh_init_helicoid(NULL, NULL);
+ exit(0);
+
res = schiff_args_init(&args, argc, argv);
if(res != RES_OK) goto error;
if(!args.ngeoms_dump && !args.wavelengths) goto exit;
diff --git a/src/schiff_mesh.c b/src/schiff_mesh.c
@@ -305,6 +305,46 @@ error:
goto exit;
}
+#include <rsys/float33.h>
+res_T
+schiff_mesh_init_helicoid
+ (struct mem_allocator* allocator,
+ struct schiff_mesh* mesh)
+{
+ const double height = 0.7;
+ const double height_total = 3;
+ const double c = height / 2*PI;
+ const double phi_max = height_total * 2*PI / height;
+ const size_t circle_nsteps = 64;
+ const double circle_step = 2*PI / (double)circle_nsteps;
+ const double circle_radius = 0.5;
+ const size_t helicoid_nsteps = 256;
+ const double helicoid_step = phi_max / (double)helicoid_nsteps;
+ const double helicoid_radius = 1.0;
+ size_t icircle, ihelicoid;
+ /*ASSERT(allocator && mesh);*/
+
+ FOR_EACH(ihelicoid, 0, helicoid_nsteps) {
+ const double phi = (double)ihelicoid * helicoid_step;
+ const double cos_phi = cos(phi);
+ const double sin_phi = sin(phi);
+
+ FOR_EACH(icircle, 0, circle_nsteps) {
+ double x, y, z;
+ const double theta = (double)icircle * circle_step;
+ const double circle_x = circle_radius*cos(theta) + helicoid_radius;
+ const double circle_y = circle_radius*sin(theta) + helicoid_radius;
+
+ x = circle_x * cos_phi;
+ y = circle_x * sin_phi;
+ z = circle_y + c*phi;
+ /* TODO rotate the x, y and z coordinates with respect to the helocoid
+ * slope */
+ }
+ }
+ return RES_OK;
+}
+
void
schiff_mesh_release(struct schiff_mesh* mesh)
{
diff --git a/src/schiff_mesh.h b/src/schiff_mesh.h
@@ -64,6 +64,11 @@ schiff_mesh_init_cylinder
struct schiff_mesh* mesh,
const unsigned nslices);
+extern LOCAL_SYM res_T
+schiff_mesh_init_helicoid
+ (struct mem_allocator* allocator,
+ struct schiff_mesh* mesh);
+
extern LOCAL_SYM void
schiff_mesh_release
(struct schiff_mesh* mesh);