summaryrefslogtreecommitdiff
path: root/src/lib/evas
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-05-29 17:18:23 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-05-29 17:20:29 +0200
commit0acf23857fccc300727c32aa5ef0583953528d5d (patch)
tree34104bab144076975df7829952a65fc5809cec73 /src/lib/evas
parentc937aab8c071102710bf0856f0197c18a96ced35 (diff)
eina: beginning of a generic quaternion API.
Diffstat (limited to 'src/lib/evas')
-rw-r--r--src/lib/evas/canvas/evas_map.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/src/lib/evas/canvas/evas_map.c b/src/lib/evas/canvas/evas_map.c
index 86ceebeba5..bd7e51b99b 100644
--- a/src/lib/evas/canvas/evas_map.c
+++ b/src/lib/evas/canvas/evas_map.c
@@ -1047,6 +1047,9 @@ EAPI void
1047evas_map_util_quat_rotate(Evas_Map *m, double qx, double qy, double qz, 1047evas_map_util_quat_rotate(Evas_Map *m, double qx, double qy, double qz,
1048 double qw, double cx, double cy, double cz) 1048 double qw, double cx, double cy, double cz)
1049{ 1049{
1050 Eina_Quaternion q;
1051 Eina_Point_3D c;
1052
1050 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP); 1053 MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
1051 return; 1054 return;
1052 MAGIC_CHECK_END(); 1055 MAGIC_CHECK_END();
@@ -1056,33 +1059,28 @@ evas_map_util_quat_rotate(Evas_Map *m, double qx, double qy, double qz,
1056 p = m->points; 1059 p = m->points;
1057 p_end = p + m->count; 1060 p_end = p + m->count;
1058 1061
1059 for (; p < p_end; p++) 1062 q.x = qx;
1060 { 1063 q.y = qy;
1061 double x, y, z, uvx, uvy, uvz, uuvx, uuvy, uuvz; 1064 q.z = qz;
1062 1065 q.w = qw;
1063 x = p->x - cx;
1064 y = p->y - cy;
1065 z = p->z - cz;
1066 1066
1067 uvx = qy * z - qz * y; 1067 c.x = cx;
1068 uvy = qz * x - qx * z; 1068 c.y = cy;
1069 uvz = qx * y - qy * x; 1069 c.z = cz;
1070 1070
1071 uuvx = qy * uvz - qz * uvy; 1071 for (; p < p_end; p++)
1072 uuvy = qz * uvx - qx * uvz; 1072 {
1073 uuvz = qx * uvy - qy * uvx; 1073 Eina_Point_3D current;
1074 1074
1075 uvx *= (2.0f * qw); 1075 current.x = p->x;
1076 uvy *= (2.0f * qw); 1076 current.y = p->y;
1077 uvz *= (2.0f * qw); 1077 current.z = p->z;
1078 1078
1079 uuvx *= 2.0f; 1079 eina_quaternion_rotate(&current, &c, &q);
1080 uuvy *= 2.0f;
1081 uuvz *= 2.0f;
1082 1080
1083 p->px = p->x = cx + x + uvx + uuvx; 1081 p->px = p->x = current.x;
1084 p->py = p->y = cy + y + uvy + uuvy; 1082 p->py = p->y = current.y;
1085 p->z = cz + z + uvz + uuvz; 1083 p->z = current.z;
1086 } 1084 }
1087} 1085}
1088 1086