GTS Library Reference Manual |
---|
#include <gts.h> #define GTS_TRIANGLE_CLASS (klass) #define GTS_TRIANGLE (obj) #define GTS_IS_TRIANGLE (obj) GtsTriangleClass; GtsTriangle; GtsTriangleClass* gts_triangle_class (void); GtsTriangle* gts_triangle_new (GtsTriangleClass *klass, GtsEdge *e1, GtsEdge *e2, GtsEdge *e3);void gts_triangle_set (GtsTriangle *triangle, GtsEdge *e1, GtsEdge *e2, GtsEdge *e3);gdouble gts_triangle_area (GtsTriangle *t);gdouble gts_triangle_perimeter (GtsTriangle *t);gdouble gts_triangle_quality (GtsTriangle *t);void gts_triangle_normal (GtsTriangle *t,gdouble *x,gdouble *y,gdouble *z);void gts_triangle_revert (GtsTriangle *t);gdouble gts_triangle_orientation (GtsTriangle *t); GtsTriangle* gts_triangle_is_duplicate (GtsTriangle *t);gdouble gts_triangles_angle (GtsTriangle *t1, GtsTriangle *t2);gboolean gts_triangles_are_compatible (GtsTriangle *t1, GtsTriangle *t2, GtsEdge *e); GtsTriangle* gts_triangle_enclosing (GtsTriangleClass *klass,GSList *points,gdouble scale); GtsEdge* gts_triangles_common_edge (GtsTriangle *t1, GtsTriangle *t2);guint gts_triangle_neighbor_number (GtsTriangle *t);GSList * gts_triangle_neighbors (GtsTriangle *t);void gts_triangle_vertices_edges (GtsTriangle *t, GtsEdge *e, GtsVertex **v1, GtsVertex **v2, GtsVertex **v3, GtsEdge **e1, GtsEdge **e2, GtsEdge **e3); GtsVertex* gts_triangle_vertex_opposite (GtsTriangle *t, GtsEdge *e); GtsEdge* gts_triangle_edge_opposite (GtsTriangle *t, GtsVertex *v);void gts_triangle_vertices (GtsTriangle *t, GtsVertex **v1, GtsVertex **v2, GtsVertex **v3); #define gts_triangle_vertex (t)gboolean gts_triangle_is_ok (GtsTriangle *t); GtsTriangle* gts_triangle_use_edges (GtsEdge *e1, GtsEdge *e2, GtsEdge *e3); GtsPoint* gts_triangle_circumcircle_center (GtsTriangle *t, GtsPointClass *point_class); GtsObject* gts_triangle_is_stabbed (GtsTriangle *t, GtsPoint *p,gdouble *orientation);gboolean gts_triangles_are_folded (GSList *triangles, GtsVertex *A, GtsVertex *B,gdouble max);GSList * gts_triangles_from_edges (GSList *edges);void gts_triangle_interpolate_height (GtsTriangle *t, GtsPoint *p);
A GtsTriangle is defined by three GtsEdge. They are oriented, the normal to the triangle points toward an observer seing the three edges in counter-clockwise order.
When destroying a GtsTriangle, all the edges not used by another triangle are also destroyed. This default behaviour can be changed punctually by setting the global variable gts_allow_floating_edges to TRUE. You must not forget to set this variable back to FALSE as all the algorithms of GTS assume the default behaviour.
#define GTS_TRIANGLE_CLASS(klass)
Casts klass
to GtsTriangleClass.
klass : | a descendant of GtsTriangleClass. |
#define GTS_IS_TRIANGLE(obj)
Evaluates to TRUE if obj
is a descendant of GtsTriangle, FALSE otherwise.
obj : | a pointer to test. |
typedef struct { GtsObjectClass parent_class; } GtsTriangleClass;
The triangle class, just derived from GtsObject.
typedef struct { GtsObject object; GtsEdge * e1; GtsEdge * e2; GtsEdge * e3; } GtsTriangle;
The triangle object.
GtsObject object ; | Parent object. |
GtsEdge *e1 ; | First edge. |
GtsEdge *e2 ; | Second edge. |
GtsEdge *e3 ; | Third edge. |
GtsTriangle* gts_triangle_new (GtsTriangleClass *klass, GtsEdge *e1, GtsEdge *e2, GtsEdge *e3);
klass : | |
e1 : | a GtsEdge. |
e2 : | another GtsEdge touching |
e3 : | another GtsEdge touching both |
Returns : | a new GtsTriangle having |
void gts_triangle_set (GtsTriangle *triangle, GtsEdge *e1, GtsEdge *e2, GtsEdge *e3);
Sets the edge of triangle
to e1
, e2
and e3
while checking that they
define a valid triangle.
triangle : | a GtsTriangle. |
e1 : | a GtsEdge. |
e2 : | another GtsEdge touching |
e3 : | another GtsEdge touching both |
gdouble gts_triangle_area (GtsTriangle *t);
t : | a GtsTriangle. |
Returns : | the area of the triangle |
gdouble gts_triangle_perimeter (GtsTriangle *t);
t : | a GtsTriangle. |
Returns : | the perimeter of the triangle |
gdouble gts_triangle_quality (GtsTriangle *t);
The quality of a triangle is defined as the ratio of its surface to its perimeter relative to this same ratio for an equilateral triangle with the same area. The quality is then one for an equilateral triangle and tends to zero for a very stretched triangle.
t : | a GtsTriangle. |
Returns : | the quality of the triangle |
void gts_triangle_normal (GtsTriangle *t,gdouble *x,gdouble *y,gdouble *z);
Computes the coordinates of the oriented normal of t
as the
cross-product of two edges, using the left-hand rule. The normal is
not normalized. If this triangle is part of a closed and oriented
surface, the normal points to the outside of the surface.
t : | a GtsTriangle. |
x : | the x coordinate of the normal. |
y : | the y coordinate of the normal. |
z : | the z coordinate of the normal. |
void gts_triangle_revert (GtsTriangle *t);
Changes the orientation of triangle t
, turning it inside out.
t : | a GtsTriangle. |
gdouble gts_triangle_orientation (GtsTriangle *t);
Checks for the orientation of the plane (x,y) projection of a
triangle. See gts_point_orientation()
for details. This function
is geometrically robust.
t : | a GtsTriangle. |
Returns : | a number depending on the orientation of the vertices of |
GtsTriangle* gts_triangle_is_duplicate (GtsTriangle *t);
t : | a GtsTriangle. |
Returns : | a GtsTriangle different from |
gdouble gts_triangles_angle (GtsTriangle *t1, GtsTriangle *t2);
t1 : | a GtsTriangle. |
t2 : | a GtsTriangle. |
Returns : | the value (in radians) of the angle between |
gboolean gts_triangles_are_compatible (GtsTriangle *t1, GtsTriangle *t2, GtsEdge *e);
Checks if t1
and t2
have compatible orientations i.e. if t1
and
t2
can be part of the same surface without conflict in the surface
normal orientation.
t1 : | a GtsTriangle. |
t2 : | a GtsTriangle. |
e : | a GtsEdge used by both |
Returns : | TRUE if |
GtsTriangle* gts_triangle_enclosing (GtsTriangleClass *klass,GSList *points,gdouble scale);
Builds a new triangle (including new vertices and edges) enclosing
the plane projection of all the points in points
. This triangle is
equilateral and encloses a rectangle defined by the maximum and
minimum x and y coordinates of the points. scale
is an homothetic
scaling factor. If equal to one, the triangle encloses exactly the
enclosing rectangle.
klass : | the class of the new triangle. |
points : | a list of GtsPoint. |
scale : | a scaling factor (must be larger than one). |
Returns : | a new GtsTriangle. |
GtsEdge* gts_triangles_common_edge (GtsTriangle *t1, GtsTriangle *t2);
t1 : | a GtsTriangle. |
t2 : | a GtsTriangle. |
Returns : | a GtsEdge common to both |
guint gts_triangle_neighbor_number (GtsTriangle *t);
t : | a GtsTriangle. |
Returns : | the number of triangles neighbors of |
GSList * gts_triangle_neighbors (GtsTriangle *t);
t : | a GtsTriangle. |
Returns : | a list of GtsTriangle neighbors of |
void gts_triangle_vertices_edges (GtsTriangle *t, GtsEdge *e, GtsVertex **v1, GtsVertex **v2, GtsVertex **v3, GtsEdge **e1, GtsEdge **e2, GtsEdge **e3);
Given t
and e
, returns v1
, v2
, v3
, e1
, e2
and e3
. e1
has v1
and v2
as vertices, e2
has v2
and v3
as vertices
and e3
has v3
and v1
as vertices. v1
, v2
and v3
respects
the orientation of t
. If e
is not NULL, e1
and e
are
identical.
t : | a GtsTriangle. |
e : | a GtsEdge belonging to the edges of |
v1 : | a GtsVertex used by |
v2 : | a GtsVertex used by |
v3 : | a GtsVertex used by |
e1 : | a GtsEdge used by |
e2 : | a GtsEdge used by |
e3 : | a GtsEdge used by |
GtsVertex* gts_triangle_vertex_opposite (GtsTriangle *t, GtsEdge *e);
This function fails if e
is not an edge of t
.
t : | a GtsTriangle. |
e : | a GtsEdge used by |
Returns : | a GtsVertex, vertex of |
GtsEdge* gts_triangle_edge_opposite (GtsTriangle *t, GtsVertex *v);
t : | a GtsTriangle. |
v : | a GtsVertex of |
Returns : | the edge of |
void gts_triangle_vertices (GtsTriangle *t, GtsVertex **v1, GtsVertex **v2, GtsVertex **v3);
Fills v1
, v2
and v3
with the oriented set of vertices, summits of t
.
t : | a GtsTriangle. |
v1 : | a pointer on a GtsVertex. |
v2 : | a pointer on a GtsVertex. |
v3 : | a pointer on a GtsVertex. |
#define gts_triangle_vertex(t)
Evaluates to the GtsVertex of t
not used by t->e1
.
t : | a GtsTriangle. |
gboolean gts_triangle_is_ok (GtsTriangle *t);
t : | a GtsTriangle. |
Returns : | TRUE if |
GtsTriangle* gts_triangle_use_edges (GtsEdge *e1, GtsEdge *e2, GtsEdge *e3);
e1 : | a GtsEdge. |
e2 : | a GtsEdge. |
e3 : | a GtsEdge. |
Returns : | a GtsTriangle having |
GtsPoint* gts_triangle_circumcircle_center (GtsTriangle *t, GtsPointClass *point_class);
t : | a GtsTriangle. |
point_class : | |
Returns : | a new GtsPoint, center of the circumscribing circle of |
GtsObject* gts_triangle_is_stabbed (GtsTriangle *t, GtsPoint *p,gdouble *orientation);
t : | a GtsTriangle. |
p : | a GtsPoint. |
orientation : | a pointer or NULL. |
Returns : | one of the vertices of |
gboolean gts_triangles_are_folded (GSList *triangles, GtsVertex *A, GtsVertex *B,gdouble max);
Given a list of triangles sharing A
and B
as vertices, checks if any
two triangles in the list make an angle larger than a given value defined
by max
.
triangles : | a list of GtsTriangle. |
A : | a GtsVertex. |
B : | another GtsVertex. |
max : | the maximum value of the square of the cosine of the angle between two triangles. |
Returns : | TRUE if any pair of triangles in |
GSList * gts_triangles_from_edges (GSList *edges);
Builds a list of unique triangles which have one of their edges in edges
.
edges : | a list of GtsEdge. |
Returns : | the list of triangles. |
void gts_triangle_interpolate_height (GtsTriangle *t, GtsPoint *p);
Fills the z-coordinate of point p
belonging to the plane
projection of triangle t
with the linearly interpolated value of
the z-coordinates of the vertices of t
.
t : | a GtsTriangle. |
p : | a GtsPoint. |
<<< Edges | Faces >>> |