Name
Vectors and matrices -- simple operations on vectors and matrices.
Synopsis
#include <gts.h>
typedef GtsVector[3];
#define gts_vector_init (v, p1, p2)
#define gts_vector_scalar (v1, v2)
#define gts_vector_cross (C,A,B)
void gts_vector_print (GtsVector v,
FILE *fptr);
typedef GtsMatrix;
GtsMatrix* gts_matrix_new (gdouble a00,
gdouble a01,
gdouble a02,
gdouble a10,
gdouble a11,
gdouble a12,
gdouble a20,
gdouble a21,
gdouble a22);
GtsMatrix* gts_matrix_transpose (GtsMatrix *m);
gdouble gts_matrix_determinant (GtsMatrix *m);
GtsMatrix* gts_matrix_inverse (GtsMatrix *m);
GtsMatrix* gts_matrix_projection (GtsTriangle *t);
GtsMatrix* gts_matrix_product (GtsMatrix *m1,
GtsMatrix *m2);
guint gts_matrix_compatible_row (GtsMatrix *A,
GtsVector b,
guint n,
GtsVector A1,
gdouble b1);
guint gts_matrix_quadratic_optimization
(GtsMatrix *A,
GtsVector b,
guint n,
GtsMatrix *H,
GtsVector c);
void gts_matrix_print (GtsMatrix *m,
FILE *fptr);
void gts_matrix_destroy (GtsMatrix *m); |
Description
The functions described in this section allow to perform simple transformations on point coordinates. In particular projection onto a plane passing through the vertices of a given triangle or quadratic optimization problems.
Details
GtsVector[3]
typedef gdouble GtsVector[3]; |
A GtsVector is just an array of three coordinates.
gts_vector_init()
#define gts_vector_init(v, p1, p2) |
Given two points p1 and p2, fills v with the coordinates of vector p1->p2.
gts_vector_scalar()
#define gts_vector_scalar(v1, v2) |
Given two vectors v1 and v2 evaluates to the scalar product v1.v2.
gts_vector_cross()
#define gts_vector_cross(C,A,B) |
Given two vectors A and B fills C with the coordinates of the cross-product A^B.
gts_vector_print ()
void gts_vector_print (GtsVector v,
FILE *fptr); |
Print s to file fptr.
GtsMatrix
typedef GtsVector GtsMatrix; |
A GtsMatrix is a 3x3 matrix.
gts_matrix_new ()
GtsMatrix* gts_matrix_new (gdouble a00,
gdouble a01,
gdouble a02,
gdouble a10,
gdouble a11,
gdouble a12,
gdouble a20,
gdouble a21,
gdouble a22); |
Allocates memory and initializes a new GtsMatrix.
gts_matrix_determinant ()
gdouble gts_matrix_determinant (GtsMatrix *m); |
gts_matrix_projection ()
Creates a new GtsMatrix representing the projection onto a plane of normal
given by t.
gts_matrix_compatible_row ()
guint gts_matrix_compatible_row (GtsMatrix *A,
GtsVector b,
guint n,
GtsVector A1,
gdouble b1); |
Given a system of n constraints A.x=b adds to it the compatible
constraints defined by A1.x=b1. The compatibility is determined
by insuring that the resulting system is well-conditioned (see
Lindstrom and Turk (1998, 1999)).
gts_matrix_quadratic_optimization ()
guint gts_matrix_quadratic_optimization
(GtsMatrix *A,
GtsVector b,
guint n,
GtsMatrix *H,
GtsVector c); |
Solve a quadratic optimization problem: Given a quadratic objective function
f which can be written as: f(x) = x^t.H.x + c^t.x + k, where H is the
symmetric positive definite Hessian of f and k is a constant, find the
minimum of f subject to the set of n prior linear constraints, defined by
the first n rows of A and b (A.x = b). The new constraints given by
the minimization are added to A and b only if they are linearly
independent as determined by gts_matrix_compatible_row().
gts_matrix_print ()
void gts_matrix_print (GtsMatrix *m,
FILE *fptr); |
Print m to file fptr.
gts_matrix_destroy ()
Free all the memory allocated for m.