9607df393d7df3c99a3fd67e287ea2912087ca36
[alexxy/gromacs.git] / include / 3dview.h
1 /*
2  * $Id$
3  * 
4  *       This source code is part of
5  * 
6  *        G   R   O   M   A   C   S
7  * 
8  * GROningen MAchine for Chemical Simulations
9  * 
10  *               VERSION 2.0
11  * 
12  * Copyright (c) 1991-1999
13  * BIOSON Research Institute, Dept. of Biophysical Chemistry
14  * University of Groningen, The Netherlands
15  * 
16  * Please refer to:
17  * GROMACS: A message-passing parallel molecular dynamics implementation
18  * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19  * Comp. Phys. Comm. 91, 43-56 (1995)
20  * 
21  * Also check out our WWW page:
22  * http://md.chem.rug.nl/~gmx
23  * or e-mail to:
24  * gromacs@chem.rug.nl
25  * 
26  * And Hey:
27  * Good ROcking Metal Altar for Chronical Sinners
28  */
29
30 #ifndef _3dview_h
31 #define _3dview_h
32
33 static char *SRCID_3dview_h = "$Id$";
34 #ifdef HAVE_CONFIG_H
35 #include <config.h>
36 #endif
37 #define WW 3
38
39 typedef real vec4[4];
40
41 typedef real mat4[4][4];
42
43 typedef int  iv2[2];
44
45 typedef struct {
46   matrix box;
47   vec4   eye,origin;    /* The eye and origin position          */
48   mat4   proj;          /* Projection matrix                    */
49   mat4   Rot;           /* Total rotation matrix                */
50   real   sc_x,sc_y;     /* Scaling for aspect ratio             */
51 } t_3dview;
52
53 extern void print_m4(FILE *fp,char *s,mat4 A);
54
55 extern void print_v4(FILE *fp,char *s,int dim,real *a);
56
57 extern void m4_op(mat4 m,rvec x,vec4 v);
58
59 extern void unity_m4(mat4 m);
60
61 extern void mult_matrix(mat4 A, mat4 B, mat4 C);
62
63 extern void rotate(int axis, real angle, mat4 A);
64
65 extern void translate(real tx, real ty, real tz, mat4 A);
66
67 extern void m4_op(mat4 m,rvec x,vec4 v);
68
69 extern void calculate_view(t_3dview *view);
70
71 extern t_3dview *init_view(matrix box);
72 /* Generate the view matrix from the eye pos and the origin,
73  * applying also the scaling for the aspect ration.
74  * There is no accompanying done_view routine: the struct can simply
75  * be sfree'd.
76  */
77
78 /* The following options are present on the 3d struct:
79  * zoom (scaling)
80  * rotate around the center of the box
81  * reset the view
82  */
83
84 extern bool zoom_3d(t_3dview *view,real fac);
85 /* Zoom in or out with factor fac, returns TRUE when zoom succesful,
86  * FALSE otherwise.
87  */
88
89 extern void rotate_3d(t_3dview *view,int axis,bool bPositive);
90 /* Rotate the eye around the center of the box, around axis */
91
92 extern void translate_view(t_3dview *view,int axis,bool bPositive);
93 /* Translate the origin at which one is looking */
94
95 extern void reset_view(t_3dview *view);
96 /* Reset the viewing to the initial view */
97
98 #endif
99