-
Notifications
You must be signed in to change notification settings - Fork 21
/
ref_math.h
57 lines (43 loc) · 2.11 KB
/
ref_math.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* Copyright 2006, 2014, 2021 United States Government as represented
* by the Administrator of the National Aeronautics and Space
* Administration. No copyright is claimed in the United States under
* Title 17, U.S. Code. All Other Rights Reserved.
*
* The refine version 3 unstructured grid adaptation platform is
* licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#ifndef REF_MATH_H
#define REF_MATH_H
#include <math.h>
#include "ref_defs.h"
BEGIN_C_DECLORATION
#define ref_math_dot(a, b) ((a)[0] * (b)[0] + (a)[1] * (b)[1] + (a)[2] * (b)[2])
#define ref_math_pi (3.14159265358979)
#define ref_math_in_degrees(radians) ((radians)*180.0 / 3.14159265358979)
#define ref_math_in_radians(degrees) ((degrees) / 180.0 * 3.14159265358979)
/* tester : printf(" %e / %e = %e \n",n,d,n/d) */
#define ref_math_divisible(n, d) (ABS(1.0e20 * d) > ABS(n))
#define ref_math_int_addable(a, b) \
((long)(REF_INT_MAX) >= ((long)(a) + (long)(b)) && \
((long)(a) + (long)(b)) >= (long)(REF_INT_MIN))
#define ref_math_int_multipliable(a, b) \
((long)(REF_INT_MAX) >= ((long)(a) * (long)(b)) && \
((long)(a) * (long)(b)) >= (long)(REF_INT_MIN))
#define ref_math_cross_product(v0, v1, product) \
(product)[0] = (v0)[1] * (v1)[2] - (v0)[2] * (v1)[1]; \
(product)[1] = (v0)[2] * (v1)[0] - (v0)[0] * (v1)[2]; \
(product)[2] = (v0)[0] * (v1)[1] - (v0)[1] * (v1)[0];
REF_FCN REF_STATUS ref_math_normalize(REF_DBL *normal);
REF_FCN REF_STATUS ref_math_orthonormal_system(REF_DBL *orth0, REF_DBL *orth1,
REF_DBL *orth2);
END_C_DECLORATION
#endif /* REF_MATH_H */