~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/display/nr-3dutils.h

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __NR_3DUTILS_H__
 
2
#define __NR_3DUTILS_H__
 
3
 
 
4
/*
 
5
 * 3D utils. Definition of gdouble vectors of dimension 3 and of some basic
 
6
 * functions.
 
7
 *   This looks redundant, why not just use Geom::Point for this?
 
8
 *
 
9
 * Authors:
 
10
 *   Jean-Rene Reinhard <jr@komite.net>
 
11
 *
 
12
 * Copyright (C) 2007 authors
 
13
 *
 
14
 * Released under GNU GPL, read the file 'COPYING' for more information
 
15
 */
 
16
 
 
17
#include <gdk/gdktypes.h>
 
18
#include <2geom/forward.h>
 
19
 
 
20
struct NRPixBlock;
 
21
 
 
22
namespace NR {
 
23
 
 
24
#define X_3D 0
 
25
#define Y_3D 1
 
26
#define Z_3D 2
 
27
 
 
28
/**
 
29
 * a type of 3 gdouble components vectors
 
30
 */
 
31
typedef gdouble Fvector[3];
 
32
 
 
33
/**
 
34
 * The eye vector
 
35
 */
 
36
const static Fvector EYE_VECTOR = {0, 0, 1};
 
37
 
 
38
/**
 
39
 * returns the euclidian norm of the vector v
 
40
 *
 
41
 * \param v a reference to a vector with double components
 
42
 * \return the euclidian norm of v
 
43
 */
 
44
gdouble norm(const Fvector &v);
 
45
 
 
46
/**
 
47
 * Normalizes a vector
 
48
 *
 
49
 * \param v a reference to a vector to normalize
 
50
 */
 
51
void normalize_vector(Fvector &v);
 
52
 
 
53
/**
 
54
 * Computes the scalar product between two Fvectors
 
55
 *
 
56
 * \param a a Fvector reference
 
57
 * \param b a Fvector reference
 
58
 * \return the scalar product of a and b
 
59
 */
 
60
gdouble scalar_product(const Fvector &a, const Fvector &b);
 
61
 
 
62
/**
 
63
 * Computes the normalized sum of two Fvectors
 
64
 *
 
65
 * \param r a Fvector reference where we store the result
 
66
 * \param a a Fvector reference
 
67
 * \param b a Fvector reference
 
68
 */
 
69
void normalized_sum(Fvector &r, const Fvector &a, const Fvector &b);
 
70
 
 
71
/**
 
72
 * Computes the unit suface normal vector of surface given by "in" at (i, j)
 
73
 * and store it into N. "in" is a (NRPixBlock *) in mode RGBA but only the alpha
 
74
 * channel is considered as a bump map. ss is the altitude when for the alpha
 
75
 * value 255. dx and dy are the deltas used to compute in our discrete setting
 
76
 *
 
77
 * \param N a reference to a Fvector in which we store the unit surface normal
 
78
 * \param ss the surface scale
 
79
 * \param in a NRPixBlock * whose alpha channel codes the surface
 
80
 * \param i the x coordinate of the point at which we compute the normal
 
81
 * \param j the y coordinate of the point at which we compute the normal
 
82
 * \param dx the delta used in the x coordinate
 
83
 * \param dy the delta used in the y coordinate
 
84
 */
 
85
void compute_surface_normal(Fvector &N, gdouble ss, NRPixBlock *in, int i, int j, int dx, int dy);
 
86
 
 
87
/**
 
88
 * Applies the transformation matrix to (x, y, z). This function assumes that
 
89
 * trans[0] = trans[3]. x and y are transformed according to trans, z is
 
90
 * multiplied by trans[0].
 
91
 *
 
92
 * \param x a reference to a x coordinate
 
93
 * \param y a reference to a y coordinate
 
94
 * \param z a reference to a z coordinate
 
95
 * \param z a reference to a transformation matrix
 
96
 */
 
97
void convert_coord(gdouble &x, gdouble &y, gdouble &z, Geom::Matrix const &trans);
 
98
 
 
99
} /* namespace NR */
 
100
 
 
101
#endif /* __NR_3DUTILS_H__ */
 
102
/*
 
103
  Local Variables:
 
104
  mode:c++
 
105
  c-file-style:"stroustrup"
 
106
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
107
  indent-tabs-mode:nil
 
108
  fill-column:99
 
109
  End:
 
110
*/
 
111
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :