1
#include <libnr/nr-matrix-fns.h>
5
Matrix elliptic_quadratic_form(Matrix const &m) {
6
double const od = m[0] * m[1] + m[2] * m[3];
7
return Matrix((m[0]*m[0] + m[1]*m[1]), od,
8
od, (m[2]*m[2] + m[3]*m[3]),
10
/* def quadratic_form((a, b), (c, d)):
11
return ((a*a + c*c), a*c+b*d),(a*c+b*d, (b*b + d*d)) */
14
Eigen::Eigen(Matrix const &m) {
15
double const B = -m[0] - m[3];
16
double const C = m[0]*m[3] - m[1]*m[2];
17
double const center = -B/2.0;
18
double const delta = sqrt(B*B-4*C)/2.0;
19
values = Point(center + delta, center - delta);
20
for (int i = 0; i < 2; i++) {
21
vectors[i] = unit_vector(rot90(Point(m[0]-values[i], m[1])));
25
/** Returns just the scale/rotate/skew part of the matrix without the translation part. */
26
Matrix transform(Matrix const &m) {
27
Matrix const ret(m[0], m[1],
33
translate get_translation(Matrix const &m) {
34
return translate(m[4], m[5]);
37
void matrix_print(const gchar *say, Matrix const &m)
39
printf ("%s %g %g %g %g %g %g\n", say, m[0], m[1], m[2], m[3], m[4], m[5]);
48
c-file-style:"stroustrup"
49
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
54
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :