32#include "core/array.h"
33#include "core/geometry3D.h"
38 template<
typename _Tp, std::
size_t _Nm>
39 struct Array :
public std::array<_Tp,_Nm> {
41 Array(
const std::initializer_list<_Tp> & il){
42 std::copy(il.begin(),il.end(), this->_M_elems);
44 Array(
const plb::Array<_Tp,_Nm> & ext) {
45 for (std::size_t i = 0 ; i < _Nm ; i++) {
52 for(std::size_t i = 0 ; i < _Nm ; i++ ) {
53 (*this)[i] += __two[i];
60 for(std::size_t i = 0 ; i < _Nm ; i++ ) {
61 (*this)[i] -= __two[i];
68 for(std::size_t i = 0 ; i < _Nm ; i++ ) {
69 (*this)[i] += __two[i];
76 for(std::size_t i = 0 ; i < _Nm ; i++ ) {
77 (*this)[0] += __two.x;
78 (*this)[1] += __two.y;
79 (*this)[2] += __two.z;
86 for(std::size_t i = 0 ; i < _Nm ; i++ ) {
94 for(std::size_t i = 0 ; i < _Nm ; i++ ) {
103 std::copy(c.begin(),c.end(), this->_M_elems);
112 template<
typename _Tp, std::
size_t _Nm>
115 for (std::size_t i = 0 ; i < _Nm ; i++ ) {
116 ret[i] = one[i]+two[i];
121 template<
typename _Tp, std::
size_t _Nm>
124 for (std::size_t i = 0 ; i < _Nm ; i++ ) {
125 ret[i] = one[i]+two[i];
129 template<
typename _Tp, std::
size_t _Nm>
132 for (std::size_t i = 0 ; i < _Nm ; i++ ) {
137 template<
typename _Tp, std::
size_t _Nm>
140 for (std::size_t i = 0 ; i < _Nm ; i++ ) {
141 ret[i] = one[i]-two[i];
145 template<
typename _Tp,
typename _Tp2, std::
size_t _Nm>
148 for (std::size_t i = 0 ; i < _Nm ; i++ ) {
149 ret[i] = one[i]-two[i];
153 template<
typename _Tp, std::
size_t _Nm>
156 for (std::size_t i = 0 ; i < _Nm ; i++ ) {
162 template<
typename _Tp, std::
size_t _Nm,
typename _Tp2>
165 for (std::size_t i = 0 ; i < _Nm ; i++ ) {
171 template<
typename _Tp, std::
size_t _Nm,
typename _Tp2>
174 for (std::size_t i = 0 ; i < _Nm ; i++ ) {
180 template<
typename _Tp, std::
size_t _Nm,
typename _Tp2>
183 for (std::size_t i = 0 ; i < _Nm ; i++ ) {
189 template<
typename _Tp>
192 ret[0] = one[0]-two.x;
193 ret[1] = one[1]-two.y;
194 ret[2] = one[2]-two.z;
198 template<
typename _Tp,
typename _Tp2,
typename _Tp3>
200 result[0] = one[1]*two[2] - one[2]*two[1];
201 result[1] = one[2]*two[0] - one[0]*two[2];
202 result[2] = one[0]*two[1] - one[1]*two[0];
205 template<
typename _Tp>
212 template<
typename _Tp,
typename _Tp2>
219 template<
typename _Tp, std::
size_t _Nm>
222 for (std::size_t i = 0 ; i < _Nm ; i++ ) {
223 ret += one[i]*two[i];
228 template<
typename _Tp,
typename _Tp2, std::
size_t _Nm>
231 for (std::size_t i = 0 ; i < _Nm ; i++ ) {
232 ret += one[i]*two[i];
237 template<
typename _Tp, std::
size_t _Nm>
240 for (std::size_t i = 0 ; i < _Nm ; i++ ) {
241 ret += (one[i])*(one[i]);
243 return std::sqrt(ret);
246 template<
typename _Tp>
251 return std::atan2(
norm(cross),
dot(one,two));
254 template<
typename _Tp>
262 return (_Tp) 0.5 *
norm(cross);
265 template<
typename _Tp>
267 return sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]);
270 template<
typename _Tp>
277 _Tp normN =
norm(unitNormal);
279 area = (_Tp) 0.5 * normN;
287 template<
typename _Tp>
295 if (!isAreaWeighted) {
306 template<
typename _Tp>
308 const _Tp adj_norm =
dot(a,b)/
norm(b);
310 const _Tp hyp_norm =
norm(a);
311 const _Tp opp_norm = std::sqrt(std::pow(hyp_norm,2)-std::pow(adj_norm,2));
312 return adj_norm/opp_norm;
315 template<
typename _Tp>
320 b_l = std::sqrt(std::pow(c_l,2)-std::pow(a_l,2));
double T
Definition constant_defaults.h:118
void crossProduct(const Array< _Tp, 3 > &one, const Array< _Tp2, 3 > &two, Array< _Tp3, 3 > &result)
Definition array.h:199
_Tp angleBetweenVectors(const Array< _Tp, 3 > &one, const Array< _Tp, 3 > &two)
Definition array.h:247
Array< _Tp, _Nm > operator/(const Array< _Tp, _Nm > &one, const _Tp2 div)
Definition array.h:163
Array< _Tp, _Nm > operator-(const Array< _Tp, _Nm > &one, const Array< _Tp, _Nm > &two)
Definition array.h:138
_Tp computeCotangentFromVectors(const Array< _Tp, 3 > &a, const Array< _Tp, 3 > &b)
Definition array.h:307
void computeTriangleAreaAndUnitNormal(const Array< _Tp, 3 > &v0, const Array< _Tp, 3 > &v1, const Array< _Tp, 3 > &v2, _Tp &area, Array< _Tp, 3 > &unitNormal)
Definition array.h:271
Array< _Tp, _Nm > operator*(const Array< _Tp, _Nm > &one, const _Tp2 mul)
Definition array.h:172
_Tp computeLength(const Array< _Tp, 3 > &v)
Definition array.h:266
_Tp norm(const Array< _Tp, _Nm > &one)
Definition array.h:238
Array< _Tp, 3 > computeTriangleNormal(const Array< _Tp, 3 > &v0, const Array< _Tp, 3 > &v1, const Array< _Tp, 3 > &v2, bool isAreaWeighted)
Definition array.h:288
Array< _Tp, _Nm > operator+(const Array< _Tp, _Nm > &one, const Array< _Tp, _Nm > &two)
Definition array.h:113
_Tp dot(const Array< _Tp, _Nm > &one, const Array< _Tp, _Nm > &two)
Definition array.h:220
void computeLengthsPythagoras(const Array< _Tp, 3 > &a, const Array< _Tp, 3 > &b, _Tp &a_l, _Tp &b_l, _Tp &c_l)
Definition array.h:316
_Tp computeTriangleArea(const Array< _Tp, 3 > &v0, const Array< _Tp, 3 > &v1, const Array< _Tp, 3 > &v2)
Definition array.h:255
Array()
Definition array.h:40
Array< _Tp, _Nm > & operator/=(const _Tp &div)
Definition array.h:93
Array< _Tp, _Nm > & operator*=(const _Tp &mul)
Definition array.h:85
Array(const std::initializer_list< _Tp > &il)
Definition array.h:41
Array< _Tp, _Nm > & operator+=(const plb::Array< _Tp, _Nm > &__two)
Definition array.h:67
Array(const plb::Array< _Tp, _Nm > &ext)
Definition array.h:44
void resetToZero()
Definition array.h:106
Array< _Tp, _Nm > & operator=(const std::initializer_list< _Tp > &c)
Definition array.h:102
Array< _Tp, _Nm > & operator+=(const hemo::Array< _Tp, _Nm > &__two)
Definition array.h:51
Array< _Tp, 3 > & operator+=(const plb::Dot3D &__two)
Definition array.h:75
Array< _Tp, _Nm > & operator-=(const hemo::Array< _Tp, _Nm > &__two)
Definition array.h:59