Conic sections are represented by the following generic structure

typedef struct conic { Ts_id ts_id; /* Tina structure identifier */ unsigned int type; unsigned int label; int filler1; double a, b, c, d, e, f; /* algebraic formula */ double theta, alpha, beta; struct vec2 center; int filler2; double t1, t2; /* conic params of p1 and p2 */ int branch; /* for hyperbola only */ List *props; /* property list */ } Conic;

In **conic** the arc covered by the curve is between angles **t1** and
**t2** in radians). All angles are positive with 0 along the
**x** axis
and *P/2 along the **y** axis. The arc goes from **t1** to **t2** in
strictly ascending order, **t1** will be less than 2 *P but
**t2** may
be larger than 2 *P if the arc passes back through the **x** axis.

In **conic** the implicit algebraic equation that represents its form is
given by
**theta** is the angle of the major axis, **alpha** and **beta** are
the lengths of the semi-major and semi-minor axis respectively, so the
rotated, translated standard form of the conic equation is
The conic **type** can b any one
of

ELLIPSE HYPERBOLA DEGENERATE

with obvious meanings. The field **branch** is used to differentiate which
part of the hyperbola the data lies on.

The covariance matrix for conic data is defined by

typedef struct conic_stat /* covariance matrix etc for conic */ { Ts_id ts_id; /* Tina structure identifier */ int filler; double x[5]; double d[5]; double u[5][5]; } Conic_stat;

The location of a conic section in 3D is made explicit using the following structure:

typedef struct conic3 { Ts_id ts_id; /* Tina structure identifier */ int type; struct conic *conic; /* describes the conic in the plane */ struct vec3 origin; /* origin point on plane */ struct vec3 ex, ey, ez; /* define x, y and z axes: ez = normal */ } Conic3;

The coordinate frame in which **conic** lies is at **origin** and has axis
**ex, ey,** and **ez.** Wh re the 2D conic lies in the **xy** plane.

Conic *conic_alloc(unsigned int type) Conic3 *conic3_alloc(unsigned int type) Conic *conic_make(int type, Vec2 center, double theta, double alpha, double beta, double t1, double t2, int branch) Conic3 *conic3_make(Conic * con2, Vec3 o, Vec3 ex, Vec3 ey, Vec3 ez) Conic *conic_copy(Conic * conic) Conic3 *conic3_copy(Conic3 * con3) void conic_free(Conic * conic) void conic3_free(Conic3 *con3) void conic_format(Conic *conic) void conic3_format(Conic3 *conic) void *conic_prop_get(Conic * conic, int type, int prop)

Obvious functions for manipulating conic geometry. Note how the naming
function differs from that of other geometry to reflect the fact that as well
as representing 2D geometry the Conic data structure is also part of the r
presentation of the

Conic3.

The functions **conic_copy, conic3_copy, conic_free** and **conic3_free** copy and free the property list see proplist description for
details). The functions **conic_format** and **conic3_format** produces
a standard formatted output of conic geometry using the standard Tina *format* facility. Usually directed to the top level text display window.

Conic *conic_5pt(Vec2 p1, Vec2 p2, Vec2 p3, Vec2 p4, Vec2 p5) Conic *conic_circ_3pt(Vec2 p1, Vec2 p2, Vec2 p3) Conic *conic_ellipse_5pt(Vec2 p1, Vec2 p2, Vec2 p3, Vec2 p4, Vec2 p5, double min_aratio) Conic *conic_ellipse_3pt(Vec2 p1, Vec2 v1, Vec2 p2, Vec2 v2, Vec2 p3, double min_aratio) Conic *conic_circ_3pt(Vec2 p1, Vec2 p2, Vec2 p3)

Functions for generating conics. Prefixes **conic_, conic_ellipse_** and
**conic_circ_** fit totally general conics, ellipses only and circles only
respectively. The **min_aratio** argument of **conic_ellipse_** fun
tions determines the ellipse aspect ratio below which an ellipse fit

is
replaced with a circle fit as is the case if the fit results in a hyperbola).

**conic_** and **conic_ellipse_** functions can take either 5 points as
arguments or 2 points with tangent unit direction vectors and an additional
point.

void conic_set_ends(Conic * conic, Vec2 p1, Vec2 p2, Vec2 pmid) Vec2 conic_point(Conic * conic, double t) Vec3 conic3_point(Conic3 * con3, double t) double conic_param(Conic * conic, Vec2 p) double conic3_param(Conic3 * con3, Vec3 p3)

Functions for relating position vectors and conic parameter values.

**conic_set_ends** sets conic end point parameter values **t1** and **t2.** respectively. The mid point **pmid** is used to identify the order of
& p1 and **p2** along the conic.

Other functions convert between parameter and point values.

void conic3_negate(Conic3 * con3) Conic3 *conic3_negative(Conic3 * con3) Conic *conic_proj(Conic * conic, Mat3 proj) void conic3_transform(Conic3 * conic, Transform3 trans) Bool conic3_coincident(Conic3 * c1, Conic3 * c2, double doterror, double poserror) Bool conic3_overlap(Conic3 * c1, Conic3 * c2, float *t1, float *t2)

Transformation functions for conic geometry. The negate functions change direction of the normal of a 3D conic the 3D locations of the end points are unchanged.

**conic_proj** performs a projecti e transformation of the geometry in **conic** according to the 3X3 projection matrix **proj_mat** and return a
pointer to the transformed version.

**conic3_transform** applies the rotation and translation **trans**
directly to the **conic** geomet y structure.

**conic3_coincident** checks if **c1** and **c2** are spatially
coincident within the allowed position and rotation errors **poserror** and
**roterror** respectively.