commit 7346f5f53f8c6b4e6bb7e25b0ebdef0189fae200
parent d874bad7f655b6543839e4d05c4c6f9f16c276f9
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 19 Jan 2017 15:41:10 +0100
Store the parsed rotation in degrees
The rotation are converted in radians in solstice rather than during the
parsing of the YAML file.
Diffstat:
8 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/src/parser/solparser.c b/src/parser/solparser.c
@@ -681,11 +681,6 @@ parse_transform
} else if(!strcmp((char*)key->data.scalar.value, "rotation")) {
SETUP_MASK(ROTATION, "rotation");
res = parse_real3(parser, doc, val, -DBL_MAX, DBL_MAX, rotation);
- if(res == RES_OK) {
- rotation[0] = MDEG2RAD(rotation[0]);
- rotation[1] = MDEG2RAD(rotation[1]);
- rotation[2] = MDEG2RAD(rotation[2]);
- }
} else {
log_err(parser, key, "unknown transform parameter `%s'.\n",
key->data.scalar.value);
diff --git a/src/parser/solparser_entity.h b/src/parser/solparser_entity.h
@@ -56,7 +56,7 @@ struct solparser_entity_id { size_t i; };
#include <rsys/hash_table.h>
struct solparser_entity {
- double rotation[3];
+ double rotation[3]; /* In degrees */
double translation[3];
struct str name;
diff --git a/src/parser/solparser_geometry.h b/src/parser/solparser_geometry.h
@@ -24,7 +24,7 @@
struct solparser_object {
struct solparser_material_double_sided_id mtl2;
struct solparser_shape_id shape;
- double rotation[3];
+ double rotation[3]; /* In degrees */
double translation[3];
};
diff --git a/src/parser/test_solparser2.c b/src/parser/test_solparser2.c
@@ -166,9 +166,7 @@ main(int argc, char** argv)
entity_id = solparser_entity_get_child(entity, 1);
entity1b = solparser_get_entity(parser, entity_id);
CHECK(d3_eq(entity1b->translation, d3_splat(tmp, 0)), 1);
- tmp[0] = MDEG2RAD(3.14);
- tmp[2] = MDEG2RAD(-1);
- CHECK(d3_eq_eps(entity1b->rotation, tmp, 1.e-6), 1);
+ CHECK(d3_eq_eps(entity1b->rotation, d3(tmp, 3.14, 0, -1), 1.e-6), 1);
CHECK(strcmp("lvl1b", str_cget(&entity1b->name)), 0);
CHECK(solparser_entity_get_children_count(entity1b), 1);
CHECK(entity1b->type, SOLPARSER_ENTITY_GEOMETRY);
diff --git a/src/solstice_args.c b/src/solstice_args.c
@@ -38,7 +38,7 @@ print_help(const char* program)
{
printf(
"Usage: %s [OPTIONS] [FILE]\n"
-"Integrate the solar flux in complex solar facilities.\n",
+"Integrate the solar flux in complex solar facilities.\n\n",
program);
/* TODO print short help for the options */
}
diff --git a/src/solstice_c.h b/src/solstice_c.h
@@ -119,7 +119,7 @@ solstice_node_set_translation
static INLINE void
solstice_node_set_rotations
(struct solstice_node* node,
- const double rotations[3])
+ const double rotations[3]) /* In radians */
{
ASSERT(node && rotations && node->type != SOLSTICE_NODE_TARGET);
SANIM(node_set_rotations(&node->anim, rotations));
diff --git a/src/solstice_entity.c b/src/solstice_entity.c
@@ -150,6 +150,7 @@ create_node(struct solstice* solstice, const struct solparser_entity* entity)
struct solstice_node* node = NULL;
struct solstice_node* tgt = NULL;
struct solstice_node* child = NULL;
+ double rotation[3];
size_t i;
res_T res = RES_OK;
ASSERT(solstice && entity);
@@ -173,8 +174,11 @@ create_node(struct solstice* solstice, const struct solparser_entity* entity)
}
/* Setup the entity transform */
+ rotation[0] = MDEG2RAD(entity->rotation[0]);
+ rotation[1] = MDEG2RAD(entity->rotation[1]);
+ rotation[2] = MDEG2RAD(entity->rotation[2]);
solstice_node_set_translation(node, entity->translation);
- solstice_node_set_rotations(node, entity->rotation);
+ solstice_node_set_rotations(node, rotation);
/* Register entity anchors */
FOR_EACH(i, 0, solparser_entity_get_anchors_count(entity)) {
diff --git a/src/solstice_object.c b/src/solstice_object.c
@@ -368,6 +368,7 @@ create_shaded_shape
const struct solparser_object* obj;
const struct solparser_shape* shape;
double transform[12];
+ double rotation[3];
res_T res = RES_OK;
ASSERT(solstice && ssol_front && ssol_back && ssol_shape);
@@ -378,7 +379,10 @@ create_shaded_shape
solstice_create_ssol_material(solstice, mtl2->back, ssol_back);
/* Define the shape transformation */
- d33_rotation(transform, obj->rotation[0], obj->rotation[1], obj->rotation[2]);
+ rotation[0] = MDEG2RAD(obj->rotation[0]);
+ rotation[1] = MDEG2RAD(obj->rotation[1]);
+ rotation[2] = MDEG2RAD(obj->rotation[2]);
+ d33_rotation(transform, rotation[0], rotation[1], rotation[2]);
d3_set(transform+9, obj->translation);
shape = solparser_get_shape(solstice->parser, obj->shape);