mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 03:22:04 +00:00
fixed clutter cos functions; fixed tilt calculations in elliptic path
This commit is contained in:
parent
5b845d3940
commit
6e39efb9aa
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
||||
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:
|
||||
|
@ -111,33 +111,30 @@ clutter_behaviour_ellipse_advance (ClutterBehaviourEllipse * e,
|
||||
|
||||
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;
|
||||
ClutterFixed x2, y2;
|
||||
|
||||
while (q > G_MAXINT16)
|
||||
{
|
||||
++shift;
|
||||
|
||||
q >>= 2;
|
||||
}
|
||||
x2 = x * clutter_cosi (e->priv->angle_tilt) -
|
||||
y * clutter_sini (e->priv->angle_tilt);
|
||||
|
||||
r = clutter_sqrtx (CLUTTER_INT_TO_FIXED (q)) << shift;
|
||||
|
||||
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)",
|
||||
|
@ -171,7 +171,7 @@ ClutterFixed clutter_tani (ClutterAngle angle);
|
||||
*
|
||||
* 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:
|
||||
@ -188,7 +188,7 @@ ClutterFixed clutter_tani (ClutterAngle angle);
|
||||
*
|
||||
* 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);
|
||||
|
@ -166,7 +166,7 @@ main (int argc, char *argv[])
|
||||
case PATH_ELLIPSE:
|
||||
p_behave =
|
||||
clutter_behaviour_ellipse_new (alpha, 200, 200, 400, 300,
|
||||
0.0, 360.0, 0.0);
|
||||
0.0, 360.0, 120.0);
|
||||
break;
|
||||
|
||||
case PATH_BSPLINE:
|
||||
|
Loading…
Reference in New Issue
Block a user