1 #ifndef __SP_SPIRAL_H__
2 #define __SP_SPIRAL_H__
4 /** \file
5 * SPSpiral: <sodipodi:spiral> implementation
6 *
7 * Authors:
8 * Mitsuru Oka <oka326@parkcity.ne.jp>
9 * Lauris Kaplinski <lauris@kaplinski.com>
10 *
11 * Copyright (C) 1999-2002 Lauris Kaplinski
12 * Copyright (C) 2000-2001 Ximian, Inc.
13 *
14 * Released under GNU GPL, read the file 'COPYING' for more information
15 */
17 #include "sp-shape.h"
19 #define noSPIRAL_VERBOSE
21 #define SP_EPSILON 1e-5
22 #define SP_EPSILON_2 (SP_EPSILON * SP_EPSILON)
23 #define SP_HUGE 1e5
25 #define SPIRAL_TOLERANCE 3.0
26 #define SAMPLE_STEP (1.0/4.0) ///< step per 2PI
27 #define SAMPLE_SIZE 8 ///< sample size per one bezier
29 #define SP_TYPE_SPIRAL (sp_spiral_get_type ())
30 #define SP_SPIRAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_SPIRAL, SPSpiral))
31 #define SP_SPIRAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_SPIRAL, SPSpiralClass))
32 #define SP_IS_SPIRAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_SPIRAL))
33 #define SP_IS_SPIRAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_SPIRAL))
35 class SPSpiral;
36 class SPSpiralClass;
38 /**
39 * A spiral Shape.
40 *
41 * The Spiral shape is defined as:
42 * \verbatim
43 x(t) = rad * t^exp cos(2 * Pi * revo*t + arg) + cx
44 y(t) = rad * t^exp sin(2 * Pi * revo*t + arg) + cy \endverbatim
45 * where spiral curve is drawn for {t | t0 <= t <= 1}. The rad and arg
46 * parameters can also be represented by transformation.
47 *
48 * \todo Should I remove these attributes?
49 */
50 struct SPSpiral : public SPShape {
51 float cx, cy;
52 float exp; ///< Spiral expansion factor
53 float revo; ///< Spiral revolution factor
54 float rad; ///< Spiral radius
55 float arg; ///< Spiral argument
56 float t0;
57 };
59 /// The SPSpiral vtable.
60 struct SPSpiralClass {
61 SPShapeClass parent_class;
62 };
65 /* Standard Gtk function */
66 GType sp_spiral_get_type (void);
68 /* Lowlevel interface */
69 void sp_spiral_position_set (SPSpiral *spiral,
70 gdouble cx,
71 gdouble cy,
72 gdouble exp,
73 gdouble revo,
74 gdouble rad,
75 gdouble arg,
76 gdouble t0);
78 Geom::Point sp_spiral_get_xy (SPSpiral const *spiral,
79 gdouble t);
81 void sp_spiral_get_polar (SPSpiral const *spiral,
82 gdouble t,
83 gdouble *rad,
84 gdouble *arg);
86 bool sp_spiral_is_invalid (SPSpiral const *spiral);
91 #endif