ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/g3vector.h
Revision: 2.1
Committed: Wed Aug 12 23:07:59 2015 UTC (8 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Added Jan Wienold's evalglare to distribution

File Contents

# User Rev Content
1 greg 2.1 /*
2     ** Author: Christian Reetz ([email protected])
3     */
4     #ifndef __G3VECTOR_H
5     #define __G3VECTOR_H
6    
7     #ifdef __cplusplus
8     extern "C" {
9     #endif
10    
11    
12     #include <stdio.h>
13    
14     #include "gbasic.h"
15     #include "fvect.h"
16    
17     typedef g3Float* g3Vec;
18    
19     #define g3v_angle(v1,v2) (acos(g3v_dot((v1),(v2))))
20    
21    
22     g3Vec g3v_create();
23     void g3v_free(g3Vec v);
24     g3Vec g3v_copy(g3Vec dest,g3Vec src);
25     g3Vec g3v_zero(g3Vec v);
26    
27     g3Vec g3v_set(g3Vec v,g3Float x,g3Float y,g3Float z);
28     g3Vec g3v_sane(g3Vec v);
29    
30     g3Vec g3v_fromrad(g3Vec v,FVECT rv);
31     void g3v_torad(FVECT rv,g3Vec v);
32    
33     /*
34     ** Orderering is done component wise, with decreasing significance
35     ** Returns -1, 0 or 1 if v1 is less, equal or greater than v2
36     */
37     int g3v_epsorder(g3Vec v1,g3Vec v2);
38    
39     /*
40     ** Returns true if v1 and v2 are epsilon equal
41     */
42     int g3v_epseq(g3Vec v1,g3Vec v2);
43    
44     int g3v_epszero(g3Vec v);
45    
46     /* Euclidean length of vector */
47     g3Float g3v_length(g3Vec v);
48    
49     /*
50     ** Common operations on vectors. All routines returns zero on errors or
51     ** the result as a g3Float
52     */
53     g3Float g3v_dot(g3Vec v1,g3Vec v2);
54     g3Vec g3v_scale(g3Vec res,g3Vec v,g3Float sc);
55     g3Vec g3v_normalize(g3Vec v);
56     g3Vec g3v_cross(g3Vec res,g3Vec v1,g3Vec v2);
57     g3Vec g3v_sub(g3Vec res,g3Vec v1,g3Vec v2);
58     g3Vec g3v_add(g3Vec res,g3Vec v1,g3Vec v2);
59    
60     g3Vec g3v_rotate(g3Vec res,g3Vec v,g3Vec rnorm,g3Float ang);
61    
62     g3Vec g3v_print(g3Vec v,FILE* fp);
63     int g3v_read(g3Vec v,FILE* fp);
64    
65     #ifdef __cplusplus
66     }
67     #endif
68    
69     #endif