forked from richard-evans/vampire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvmath.hpp
101 lines (93 loc) · 4 KB
/
vmath.hpp
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//-----------------------------------------------------------------------------
//
// Vampire - A code for atomistic simulation of magnetic materials
//
// Copyright (C) 2009-2012 R.F.L.Evans
//
// Email:[email protected]
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// ----------------------------------------------------------------------------
//
///
/// @file
/// @brief Contains the vmath header namespace for sundry math utilities in vampire.
///
/// @section License
/// Use of this code, either in source or compiled form, is subject to license from the authors.
/// Copyright \htmlonly © \endhtmlonly Richard Evans, 2009-2010. All Rights Reserved.
///
/// @section info File Information
/// @author Richard Evans, [email protected]
/// @version 1.0
/// @date 04/03/2010
/// @internal
/// Created: 04/03/2010
/// Revision: ---
///=====================================================================================
///
#include<vector>
#include <cmath>
/// @namespace ns
/// @brief vmath namespace containing sundry math functions for vampire.
///
/// @internal
///=====================================================================================
///
namespace vmath{
/// @brief Function to determine if point is within a polygon.
///
/// @section License
/// Use of this code, either in source or compiled form, is subject to license from the authors.
/// Copyright \htmlonly © \endhtmlonly Richard Evans, 2009-2010. All Rights Reserved.
///
/// @section Information
/// @author Richard Evans, [email protected]
/// @version 1.0
/// @date 04/03/2010
///
/// @param[in] x x coordinate of point to be tested
/// @param[in] y y coordinate of point to be tested
/// @param[in] *polyX array of x coordinate points for the polygon
/// @param[in] *polyY array of y coordinate points for the polygon
/// @param[in] nsides number of sides of the polygon
/// @return variable returned from the function
///
/// @internal
/// Created: 04/03/2010
/// Revision: ---
///=====================================================================================
///
extern bool point_in_polygon(double, double, double*, double*, int);
extern bool point_in_polygon2(double, double, std::vector<double>&, std::vector<double>&, int);
extern std::vector<std::vector<double> > matmul(std::vector<std::vector<double> > &, std::vector<std::vector<double> > &);
extern std::vector<double> matmul(std::vector<double> &, std::vector<std::vector<double> > &);
extern std::vector<std::vector<double> > transpose(std::vector<std::vector<double> > &);
extern std::vector<std::vector<double> > set_matrix(const unsigned int, const unsigned int, std::vector<double> &);
extern std::vector<std::vector<double> > set_matrix(const unsigned int, const unsigned int);
extern void print_matrix( std::vector<std::vector<double> >&);
extern void set_rotational_matrix(double, double, double, std::vector< std::vector<double> > &, std::vector< std::vector<double> > &, std::vector< std::vector<double> > &);
extern double sign(double);
extern int sign(int);
inline int iround( double value ){
return static_cast<int>(floor( value + 0.5 ));
}
inline int iceil( double value ){
return static_cast<int>(ceil( value ));
}
extern double interpolate_m(double,double,double,double);
extern double interpolate_c(double,double,double,double);
}