2007-05-29 Tomas Frydrych <tf@openedhand.com>
+ * clutter/clutter-fixed.h:
+ (clutter_cosx):
+ (clutter_cosi):
+ Fixed wrong sign in cos -> sin tranformation.
+
+ * clutter/clutter-behaviour-ellipse.c:
+ (clutter_behaviour_ellipse_advance):
+ Replaced coordinace calculation for tilted ellipse with a sane
+ algorithm.
+
+ * examples/behave.c:
+ Added tilt parameter to the example ellptic path.
+
+2007-05-29 Tomas Frydrych <tf@openedhand.com>
+
* clutter/cogl/gles/cogl.c:
(cogl_setup_viewport):
Fixed z_camera calculation.
if (e->priv->angle_tilt)
{
- /* Problem: sqrti is not giving us sufficient precission here
- * and ClutterFixed range is too small to hold x^2+y^2 even for
- * reasonable x, y values.
+ /*
+ * x2 = r * cos (angle + tilt)
+ * y2 = r * sin (angle + tilt)
+ *
+ * These can be trasformed to the formulas below using properties of
+ * sin (a + b) and cos (a + b)
*
- * We take advantage of sqrt (a * b^2) == sqrt (a) * b,
- * and divide repeatedly by 4 until we get it into range, and then
- * multiply the result by 2 the same number of times.
*/
- ClutterFixed r;
- guint q = x*x + y*y;
- gint shift = 0;
-
- while (q > G_MAXINT16)
- {
- ++shift;
-
- q >>= 2;
- }
+ ClutterFixed x2, y2;
- r = clutter_sqrtx (CLUTTER_INT_TO_FIXED (q)) << shift;
+ x2 = x * clutter_cosi (e->priv->angle_tilt) -
+ y * clutter_sini (e->priv->angle_tilt);
- x = CFX_INT (CFX_MUL (r, clutter_cosi (angle + e->priv->angle_tilt)));
- y = CFX_INT (CFX_MUL (r, clutter_sini (angle + e->priv->angle_tilt)));
+ y2 = y * clutter_cosi (e->priv->angle_tilt) +
+ x * clutter_sini (e->priv->angle_tilt);
+
+ knot->x = CFX_INT (x2);
+ knot->y = CFX_INT (y2);
+ }
+ else
+ {
+ knot->x = x;
+ knot->y = y;
}
-
- knot->x = x;
- knot->y = y;
#if 0
g_debug ("advancing to angle %d [%d, %d] (a: %d, b: %d)",
*
* Since: 0.2
*/
-#define clutter_cosx(angle) clutter_fixed_sin((angle) - CFX_PI_2)
+#define clutter_cosx(angle) clutter_fixed_sin((angle) + CFX_PI_2)
/**
* clutter_cosi:
*
* Since: 0.2
*/
-#define clutter_cosi(angle) clutter_sini((angle) - 256)
+#define clutter_cosi(angle) clutter_sini((angle) + 256)
ClutterFixed clutter_sqrtx (ClutterFixed x);
gint clutter_sqrti (gint x);