1
#ifndef __NR_3DUTILS_H__
2
#define __NR_3DUTILS_H__
5
* 3D utils. Definition of gdouble vectors of dimension 3 and of some basic
7
* This looks redundant, why not just use Geom::Point for this?
10
* Jean-Rene Reinhard <jr@komite.net>
12
* Copyright (C) 2007 authors
14
* Released under GNU GPL, read the file 'COPYING' for more information
17
#include <gdk/gdktypes.h>
18
#include <2geom/forward.h>
29
* a type of 3 gdouble components vectors
31
typedef gdouble Fvector[3];
36
const static Fvector EYE_VECTOR = {0, 0, 1};
39
* returns the euclidian norm of the vector v
41
* \param v a reference to a vector with double components
42
* \return the euclidian norm of v
44
gdouble norm(const Fvector &v);
49
* \param v a reference to a vector to normalize
51
void normalize_vector(Fvector &v);
54
* Computes the scalar product between two Fvectors
56
* \param a a Fvector reference
57
* \param b a Fvector reference
58
* \return the scalar product of a and b
60
gdouble scalar_product(const Fvector &a, const Fvector &b);
63
* Computes the normalized sum of two Fvectors
65
* \param r a Fvector reference where we store the result
66
* \param a a Fvector reference
67
* \param b a Fvector reference
69
void normalized_sum(Fvector &r, const Fvector &a, const Fvector &b);
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
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
85
void compute_surface_normal(Fvector &N, gdouble ss, NRPixBlock *in, int i, int j, int dx, int dy);
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].
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
97
void convert_coord(gdouble &x, gdouble &y, gdouble &z, Geom::Matrix const &trans);
101
#endif /* __NR_3DUTILS_H__ */
105
c-file-style:"stroustrup"
106
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
111
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :