ug4
math_vector_functions_common_impl.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2015: G-CSC, Goethe University Frankfurt
3  * Author: Sebastian Reiter
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 ��7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., N��gel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
35 // This file supplies a general implementation of vector_functions.
36 // The methods implemented here work on every vector-type, that supports
37 // the vector-description in lgmath_vector_descriptor.h.
38 // Since this implementation is quite general it is not the fastest.
39 // One should consider implementing specializations for commonly used types
40 // like vector3 etc.
42 
43 #ifndef __H__COMMON__VECTOR_FUNCTIONS_COMMON_IMPL__
44 #define __H__COMMON__VECTOR_FUNCTIONS_COMMON_IMPL__
45 
46 #include <cmath>
47 #include <algorithm>
48 #include "common/error.h"
49 #include "common/assert.h"
50 #include "common/static_assert.h"
51 
52 namespace ug
53 {
54 
55 template <typename vector_target_t, typename vector_source_t>
56 void VecCopy(vector_target_t& target, const vector_source_t& source,
58 {
59  using std::min;
60  size_t minSize = min(target.size(), source.size());
61  for(size_t i = 0; i < minSize; ++i)
62  target[i] = source[i];
63 
64  for(size_t i = minSize; i < target.size(); ++i)
65  target[i] = fill;
66 }
67 
69 template <typename vector_t>
70 inline
71 void
72 VecAppend(vector_t& vOut, const vector_t& v1)
73 {
74  typedef typename vector_t::size_type size_type;
75  for(size_type i = 0; i < vOut.size(); ++i)
76  {
77  vOut[i] += v1[i];
78  }
79 }
80 
82 template <typename vector_t>
83 inline
84 void
85 VecAppend(vector_t& vOut, const vector_t& v1, const vector_t& v2)
86 {
87  typedef typename vector_t::size_type size_type;
88  for(size_type i = 0; i < vOut.size(); ++i)
89  {
90  vOut[i] += v1[i] + v2[i];
91  }
92 }
93 
95 template <typename vector_t>
96 inline
97 void
98 VecAppend(vector_t& vOut, const vector_t& v1, const vector_t& v2,
99  const vector_t& v3)
100 {
101  typedef typename vector_t::size_type size_type;
102  for(size_type i = 0; i < vOut.size(); ++i)
103  {
104  vOut[i] += v1[i] + v2[i] + v3[i];
105  }
106 }
107 
109 template <typename vector_t>
110 inline
111 void
112 VecAppend(vector_t& vOut, const vector_t& v1, const vector_t& v2,
113  const vector_t& v3, const vector_t& v4)
114 {
115  typedef typename vector_t::size_type size_type;
116  for(size_type i = 0; i < vOut.size(); ++i)
117  {
118  vOut[i] += v1[i] + v2[i] + v3[i] + v4[i];
119  }
120 }
121 
123 template <typename vector_t>
124 inline
125 void
126 VecScaleAppend(vector_t& vOut, typename vector_t::value_type s1, const vector_t& v1)
127 {
128  typedef typename vector_t::size_type size_type;
129  for(size_type i = 0; i < vOut.size(); ++i)
130  {
131  vOut[i] += s1 * v1[i];
132  }
133 }
134 
136 template <typename vector_t>
137 inline
138 void
139 VecScaleAppend(vector_t& vOut, typename vector_t::value_type s1, const vector_t& v1,
140  typename vector_t::value_type s2, const vector_t& v2)
141 {
142  typedef typename vector_t::size_type size_type;
143  for(size_type i = 0; i < vOut.size(); ++i)
144  {
145  vOut[i] += s1 * v1[i] + s2 * v2[i];
146  }
147 }
148 
150 template <typename vector_t>
151 inline
152 void
153 VecScaleAppend(vector_t& vOut, typename vector_t::value_type s1, const vector_t& v1,
154  typename vector_t::value_type s2, const vector_t& v2,
155  typename vector_t::value_type s3, const vector_t& v3)
156 {
157  typedef typename vector_t::size_type size_type;
158  for(size_type i = 0; i < vOut.size(); ++i)
159  {
160  vOut[i] += s1 * v1[i] + s2 * v2[i] + s3 * v3[i];
161  }
162 }
163 
165 template <typename vector_t>
166 inline
167 void
168 VecScaleAppend(vector_t& vOut, typename vector_t::value_type s1, const vector_t& v1,
169  typename vector_t::value_type s2, const vector_t& v2,
170  typename vector_t::value_type s3, const vector_t& v3,
171  typename vector_t::value_type s4, const vector_t& v4)
172 {
173  typedef typename vector_t::size_type size_type;
174  for(size_type i = 0; i < vOut.size(); ++i)
175  {
176  vOut[i] += s1 * v1[i] + s2 * v2[i] + s3 * v3[i] + s4 * v4[i];
177  }
178 }
179 
180 
182 template <typename vector_t>
183 inline
184 void
185 VecAdd(vector_t& vOut, const vector_t& v1, const vector_t& v2)
186 {
187  typedef typename vector_t::size_type size_type;
188  for(size_type i = 0; i < vOut.size(); ++i)
189  {
190  vOut[i] = v1[i] + v2[i];
191  }
192 }
193 
195 template <typename vector_t>
196 inline
197 void
198 VecAdd(vector_t& vOut, const vector_t& v1, const vector_t& v2,
199  const vector_t& v3)
200 {
201  typedef typename vector_t::size_type size_type;
202  for(size_type i = 0; i < vOut.size(); ++i)
203  {
204  vOut[i] = v1[i] + v2[i] + v3[i];
205  }
206 }
207 
209 template <typename vector_t>
210 inline
211 void
212 VecAdd(vector_t& vOut, const vector_t& v1, const vector_t& v2,
213  const vector_t& v3, const vector_t& v4)
214 {
215  typedef typename vector_t::size_type size_type;
216  for(size_type i = 0; i < vOut.size(); ++i)
217  {
218  vOut[i] = v1[i] + v2[i] + v3[i] + v4[i];
219  }
220 }
221 
223 template <typename vector_t>
224 inline
225 void
226 VecSubtract(vector_t& vOut, const vector_t& v1, const vector_t& v2)
227 {
228  typedef typename vector_t::size_type size_type;
229  for(size_type i = 0; i < vOut.size(); ++i)
230  {
231  vOut[i] = v1[i] - v2[i];
232  }
233 }
234 
236 template <typename vector_t>
237 inline
238 void
239 VecPow(vector_t& vOut, const vector_t& v1, typename vector_t::value_type s)
240 {
241  typedef typename vector_t::size_type size_type;
242  for(size_type i = 0; i < vOut.size(); ++i)
243  {
244  vOut[i] = std::pow(v1[i], s);
245  }
246 }
247 
249 template <typename vector_t>
250 inline
251 void
252 VecScale(vector_t& vOut, const vector_t& v, typename vector_t::value_type s)
253 {
254  typedef typename vector_t::size_type size_type;
255  for(size_type i = 0; i < vOut.size(); ++i)
256  {
257  vOut[i] = s * v[i];
258  }
259 }
260 
262 template <typename vector_t>
263 inline
264 void
265 VecScaleAdd(vector_t& vOut, typename vector_t::value_type s1, const vector_t& v1,
266  typename vector_t::value_type s2, const vector_t& v2)
267 {
268  typedef typename vector_t::size_type size_type;
269  for(size_type i = 0; i < vOut.size(); ++i)
270  {
271  vOut[i] = s1 * v1[i] + s2 * v2[i];
272  }
273 }
274 
276 template <typename vector_t>
277 inline
278 void
279 VecScaleAdd(vector_t& vOut, typename vector_t::value_type s1, const vector_t& v1,
280  typename vector_t::value_type s2, const vector_t& v2,
281  typename vector_t::value_type s3, const vector_t& v3)
282 {
283  typedef typename vector_t::size_type size_type;
284  for(size_type i = 0; i < vOut.size(); ++i)
285  {
286  vOut[i] = s1 * v1[i] + s2 * v2[i] + s3 * v3[i];
287  }
288 }
289 
291 template <typename vector_t>
292 inline
293 void
294 VecScaleAdd(vector_t& vOut, typename vector_t::value_type s1, const vector_t& v1,
295  typename vector_t::value_type s2, const vector_t& v2,
296  typename vector_t::value_type s3, const vector_t& v3,
297  typename vector_t::value_type s4, const vector_t& v4)
298 {
299  typedef typename vector_t::size_type size_type;
300  for(size_type i = 0; i < vOut.size(); ++i)
301  {
302  vOut[i] = s1 * v1[i] + s2 * v2[i] + s3 * v3[i] + s4 * v4[i];
303  }
304 }
305 
306 // performs linear interpolation between two MathVector<N>s.
307 template <typename vector_t>
308 inline
309 void
310 VecInterpolateLinear(vector_t& vOut, const vector_t& v1, const vector_t& v2,
311  typename vector_t::value_type interpAmount)
312 {
313  typedef typename vector_t::size_type size_type;
314  for(size_type i = 0; i < vOut.size(); ++i)
315  {
316  vOut[i] = (1. - interpAmount) * v1[i] + interpAmount * v2[i];
317  }
318 }
319 
321 template <typename vector_t>
322 inline
323 typename vector_t::value_type
324 VecLengthSq(const vector_t& v)
325 {
326  typename vector_t::value_type len = 0;
327  typedef typename vector_t::size_type size_type;
328 
329  for(size_type i = 0; i < v.size(); ++i)
330  {
331  len += v[i] * v[i];
332  }
333 
334  return len;
335 }
336 
338 template <typename vector_t>
339 inline
340 typename vector_t::value_type
341 VecLength(const vector_t& v)
342 {
343  return static_cast<typename vector_t::value_type>(
344  std::sqrt(VecLengthSq(v)));
345 }
346 
348 template <typename vector_t>
349 inline
350 typename vector_t::value_type
351 VecDistanceSq(const vector_t& v1, const vector_t& v2)
352 {
353  vector_t v;
354  VecSubtract(v, v1, v2);
355  return VecLengthSq(v);
356 }
357 
359 template <typename TVector, typename TMatrix>
360 inline
361 typename TVector::value_type
362 VecDistanceSq(const TVector& v1, const TVector& v2, const TMatrix& M)
363 {
364  TVector delta;
365  TVector deltaM;
366  VecSubtract(delta, v1, v2);
367  MatVecMult(deltaM, M, delta);
368  return VecDot(deltaM, delta);
369 }
370 
372 template <typename vector_t>
373 inline
374 typename vector_t::value_type
375 VecDistance(const vector_t& v1, const vector_t& v2)
376 {
377  return static_cast<typename vector_t::value_type>
378  (std::sqrt(VecDistanceSq(v1, v2)));
379 }
380 
382 template <typename vector_t>
383 inline
384 typename vector_t::value_type
385 VecDot(const vector_t& v1, const vector_t& v2)
386 {
387  typename vector_t::value_type dp = 0;
388  typedef typename vector_t::size_type size_type;
389 
390  for(size_type i = 0; i < v1.size(); ++i)
391  {
392  dp += v1[i] * v2[i];
393  }
394 
395  return dp;
396 }
397 
398 template <typename vector_t>
399 inline
400 typename vector_t::value_type
401 VecAngle(const vector_t& v1, const vector_t& v2)
402 {
403  typedef typename vector_t::value_type value_t;
404 
405  value_t l = sqrt(VecLengthSq(v1) * VecLengthSq(v2));
406  if(l > 0){
407  number a = VecDot(v1, v2) / l;
408  if(a >= 1)
409  return 0;
410  else if(a <= -1)
411  return PI;
412  return acos(a);
413  }
414 
415  return 0;
416 }
417 
418 template <typename vector_t>
419 inline
420 typename vector_t::value_type
421 VecAngleNorm(const vector_t& v1, const vector_t& v2)
422 {
423  number a = VecDot(v1, v2);
424  if(a >= 1)
425  return 0;
426  else if(a <= -1)
427  return PI;
428  return acos(a);
429 }
430 
434 template <typename vector_t>
435 inline
436 void
437 VecCross(vector_t& vOut, const vector_t& v1, const vector_t& v2)
438 {
439  if(&vOut != &v1 && &vOut != &v2)
440  {
441  vOut[0] = v1[1] * v2[2] - v2[1] * v1[2];
442  vOut[1] = v1[2] * v2[0] - v2[2] * v1[0];
443  vOut[2] = v1[0] * v2[1] - v2[0] * v1[1];
444  }
445  else
446  {
447  vector_t _temp;
448  _temp[0] = v1[1] * v2[2] - v2[1] * v1[2];
449  _temp[1] = v1[2] * v2[0] - v2[2] * v1[0];
450  _temp[2] = v1[0] * v2[1] - v2[0] * v1[1];
451  vOut = _temp;
452  }
453 }
454 
463 template <size_t dim>
464 inline void GenVecCross
465 (
466  MathVector<dim> & result,
467  const MathVector<dim> & v_1, const MathVector<dim> & v_2
468 )
469 {
470  /* Cf. the specializations below! */
471  UG_THROW ("The generalized vector product is defined only in 2 and 3 dimensions");
472 };
473 
475 template <>
476 inline void GenVecCross<2>
477 (
478  MathVector<2> & result,
479  const MathVector<2> & v_1, const MathVector<2> & v_2
480 )
481 {
482  result[0] = v_1[0] * v_2[1] - v_1[1] * v_2[0];
483  result[1] = 0;
484 };
485 
487 template <>
488 inline void GenVecCross<3>
489 (
490  MathVector<3> & result,
491  const MathVector<3> & v_1, const MathVector<3> & v_2
492 )
493 {
494  VecCross (result, v_1, v_2);
495 };
496 
498 template <typename vector_t>
499 inline
500 void
501 VecNormalize(vector_t& vOut, const vector_t& v)
502 {
503  typename vector_t::value_type len = VecLength(v);
504  if(len > 0)
505  VecScale(vOut, v, (typename vector_t::value_type) 1 / len);
506  else
507  vOut = v;
508 }
509 
511 template <typename vector_t>
512 inline
513 void
514 CalculateTriangleNormalNoNormalize(vector_t& vOut, const vector_t& v1,
515  const vector_t& v2, const vector_t& v3)
516 {
517  vector_t e1, e2;
518  VecSubtract(e1, v2, v1);
519  VecSubtract(e2, v3, v1);
520 
521  VecCross(vOut, e1, e2);
522 }
523 
525 template <typename vector_t>
526 inline
527 void
528 CalculateTriangleNormal(vector_t& vOut, const vector_t& v1,
529  const vector_t& v2, const vector_t& v3)
530 {
531  CalculateTriangleNormalNoNormalize(vOut, v1, v2, v3);
532  VecNormalize(vOut, vOut);
533 }
534 
536 template <typename vector_t>
537 inline
538 void
539 VecSet(vector_t& vInOut, typename vector_t::value_type s)
540 {
541  typedef typename vector_t::size_type size_type;
542  for(size_type i = 0; i < vInOut.size(); ++i)
543  {
544  vInOut[i] = s;
545  }
546 }
547 
549 template <typename vector_t>
550 inline
551 void
552 VecAdd(vector_t& vOut, const vector_t& v, typename vector_t::value_type s)
553 {
554  typedef typename vector_t::size_type size_type;
555  for(size_type i = 0; i < vOut.size(); ++i)
556  {
557  vOut[i] = v[i] + s;
558  }
559 }
560 
562 template <typename vector_t>
563 inline
564 void
565 VecSubtract(vector_t& vOut, const vector_t& v, typename vector_t::value_type s)
566 {
567  typedef typename vector_t::size_type size_type;
568  for(size_type i = 0; i < vOut.size(); ++i)
569  {
570  vOut[i] = v[i] - s;
571  }
572 }
573 
574 template <typename vector_t>
575 inline
576 typename vector_t::value_type
577 VecTwoNorm(const vector_t& v)
578 {
579  return VecLength(v);
580 }
581 
582 template <typename vector_t>
583 inline
584 typename vector_t::value_type
585 VecTwoNormSq(const vector_t& v)
586 {
587  return VecLengthSq(v);
588 }
589 
590 template <typename vector_t>
591 inline
592 typename vector_t::value_type
593 VecOneNorm(const vector_t& v)
594 {
595  typename vector_t::value_type len = 0;
596  typedef typename vector_t::size_type size_type;
597 
598  for(size_type i = 0; i < v.size(); ++i)
599  {
600  len += std::abs(v[i]);
601  }
602 
603  return len;
604 }
605 
606 template <typename vector_t>
607 inline
608 typename vector_t::value_type
609 VecPNorm(const vector_t& v, unsigned int p)
610 {
611  typename vector_t::value_type len = 0;
612  typedef typename vector_t::size_type size_type;
613 
614  for(size_type i = 0; i < v.size(); ++i)
615  {
616  len += std::pow(v[i], p);
617  }
618 
619  return std::pow(len, (typename vector_t::value_type) 1/ p);
620 }
621 
622 template <typename vector_t>
623 inline
624 typename vector_t::value_type
625 VecMaxNorm(const vector_t& v)
626 {
627  typename vector_t::value_type m = 0;
628  typedef typename vector_t::size_type size_type;
629 
630  for(size_type i = 0; i < v.size(); ++i)
631  {
632  m = std::max(m, v[i]);
633  }
634 
635  return m;
636 }
637 
638 template <typename vector_t>
639 inline
640 typename vector_t::value_type
641 VecInftyNorm(const vector_t& v)
642 {
643  return VecMaxNorm(v);
644 }
645 
646 
648 template <typename vector_t>
649 inline
650 void
651 VecElemProd(vector_t& vOut, const vector_t& v1, const vector_t& v2)
652 {
653  typedef typename vector_t::size_type size_type;
654  for(size_type i = 0; i < vOut.size(); ++i)
655  {
656  vOut[i] = v1[i] * v2[i];
657  }
658 }
659 
661 template <typename vector_t>
662 inline
663 void
664 VecElemSqrt(vector_t& vOut, const vector_t& v1)
665 {
666  typedef typename vector_t::size_type size_type;
667  for(size_type i = 0; i < vOut.size(); ++i)
668  {
669  vOut[i] = sqrt(v1[i]);
670  }
671 }
672 
674 template <typename vector_t>
675 inline
676 bool
677 VecAbsIsLess(const vector_t& v1, const vector_t& v2)
678 {
679  for(typename vector_t::size_type i = 0; i < v1.size(); ++i)
680  if (std::abs (v1[i]) >= std::abs (v2[i]))
681  return false;
682  return true;
683 }
684 
686 template <typename vector_t>
687 inline
688 bool
689 VecAbsIsLess(const vector_t& v1, const typename vector_t::value_type s)
690 {
691  for(typename vector_t::size_type i = 0; i < v1.size(); ++i)
692  if (std::abs (v1[i]) >= s)
693  return false;
694  return true;
695 }
696 
698 template <typename vector_t>
699 inline
700 bool
701 VecIsInBB(const vector_t& v, const vector_t& low, const vector_t& high)
702 {
703  for(typename vector_t::size_type i = 0; i < v.size(); ++i)
704  if (v[i] < low[i] || high[i] < v[i])
705  return false;
706  return true;
707 }
708 
709 }// end of namespace
710 
711 #endif /* __H__COMMON__MathVector_FUNCTIONS_COMMON_IMPL__ */
712 
parameterString p
parameterString s
function util fill(N, c)
#define UG_THROW(msg)
Definition: error.h:57
double number
Definition: types.h:124
void MatVecMult(vector_t_out &vOut, const matrix_t &m, const vector_t_in &v)
Matrix - Vector Multiplication.
Definition: math_matrix_vector_functions_common_impl.hpp:49
vector_t::value_type VecLength(const vector_t &v)
returns the length of v. Slower than VecLengthSq.
Definition: math_vector_functions_common_impl.hpp:341
void VecScaleAppend(vector_t &vOut, typename vector_t::value_type s1, const vector_t &v1)
Scales a Vector and adds it to a second vector.
Definition: math_vector_functions_common_impl.hpp:126
void VecCopy(vector_target_t &target, const vector_source_t &source, typename vector_target_t::value_type fill)
Copy contents between vectors of possibly different types.
Definition: math_vector_functions_common_impl.hpp:56
vector_t::value_type VecMaxNorm(const vector_t &v)
Definition: math_vector_functions_common_impl.hpp:625
void GenVecCross(MathVector< dim > &result, const MathVector< dim > &v_1, const MathVector< dim > &v_2)
calculates the usual cross product in 3d, and the (det, 0) vector as a cross product in 2d
Definition: math_vector_functions_common_impl.hpp:465
void VecSet(vector_t &vInOut, typename vector_t::value_type s)
Set each vector component to scalar (componentwise)
Definition: math_vector_functions_common_impl.hpp:539
void VecScaleAdd(vector_t &vOut, typename vector_t::value_type s1, const vector_t &v1, typename vector_t::value_type s2, const vector_t &v2)
Scales two Vectors, adds them and returns the sum in a third vector.
Definition: math_vector_functions_common_impl.hpp:265
vector_t::value_type VecTwoNormSq(const vector_t &v)
Definition: math_vector_functions_common_impl.hpp:585
vector_t::value_type VecOneNorm(const vector_t &v)
Definition: math_vector_functions_common_impl.hpp:593
void VecNormalize(vector_t &vOut, const vector_t &v)
scales a vector_t to unit length
Definition: math_vector_functions_common_impl.hpp:501
void CalculateTriangleNormalNoNormalize(vector_t &vOut, const vector_t &v1, const vector_t &v2, const vector_t &v3)
Calculates a triangle-normal in 3d (no normalization is performed).
Definition: math_vector_functions_common_impl.hpp:514
void VecSubtract(vector_t &vOut, const vector_t &v1, const vector_t &v2)
subtracts v2 from v1 and stores the result in a vOut
Definition: math_vector_functions_common_impl.hpp:226
vector_t::value_type VecAngle(const vector_t &v1, const vector_t &v2)
returns the angle between two vectors in radiants
Definition: math_vector_functions_common_impl.hpp:401
vector_t::value_type VecDistanceSq(const vector_t &v1, const vector_t &v2)
returns the squared distance of two vector_ts.
Definition: math_vector_functions_common_impl.hpp:351
void CalculateTriangleNormal(vector_t &vOut, const vector_t &v1, const vector_t &v2, const vector_t &v3)
Calculates a triangle-normal in 3d (output has length 1).
Definition: math_vector_functions_common_impl.hpp:528
void VecAppend(vector_t &vOut, const vector_t &v1)
adds a MathVector<N> to a second one
Definition: math_vector_functions_common_impl.hpp:72
vector_t::value_type VecLengthSq(const vector_t &v)
returns the squared length of v. Faster than VecLength.
Definition: math_vector_functions_common_impl.hpp:324
vector_t::value_type VecDistance(const vector_t &v1, const vector_t &v2)
returns the distance of two vector_ts.
Definition: math_vector_functions_common_impl.hpp:375
void VecAdd(vector_t &vOut, const vector_t &v1, const vector_t &v2)
adds two MathVector<N>s and stores the result in a third one
Definition: math_vector_functions_common_impl.hpp:185
void VecScale(vector_t &vOut, const vector_t &v, typename vector_t::value_type s)
scales a MathVector<N>
Definition: math_vector_functions_common_impl.hpp:252
vector_t::value_type VecTwoNorm(const vector_t &v)
Definition: math_vector_functions_common_impl.hpp:577
void VecCross(vector_t &vOut, const vector_t &v1, const vector_t &v2)
calculates the cross product of two Vectors of dimension 3. It makes no sense to use VecCross for vec...
Definition: math_vector_functions_common_impl.hpp:437
void VecPow(vector_t &vOut, const vector_t &v1, typename vector_t::value_type s)
component-wise exponentiation of a vector
Definition: math_vector_functions_common_impl.hpp:239
vector_t::value_type VecAngleNorm(const vector_t &v1, const vector_t &v2)
returns the angle between two vectors of length 1 in radiants
Definition: math_vector_functions_common_impl.hpp:421
void VecInterpolateLinear(vector_t &vOut, const vector_t &v1, const vector_t &v2, typename vector_t::value_type interpAmount)
Definition: math_vector_functions_common_impl.hpp:310
vector_t::value_type VecDot(const vector_t &v1, const vector_t &v2)
returns the dot-product of two vector_ts
Definition: math_vector_functions_common_impl.hpp:385
vector_t::value_type VecInftyNorm(const vector_t &v)
Definition: math_vector_functions_common_impl.hpp:641
vector_t::value_type VecPNorm(const vector_t &v, unsigned int p)
Definition: math_vector_functions_common_impl.hpp:609
size_t target(SM_edge< typename T::value_type > const &e, ug::BidirectionalMatrix< T > const &m)
Definition: bidirectional_boost.h:100
size_t source(SM_edge< typename T::value_type > const &e, ug::BidirectionalMatrix< T > const &)
Definition: bidirectional_boost.h:94
the ug namespace
bool VecIsInBB(const vector_t &v, const vector_t &low, const vector_t &high)
checks if the given point is in the bounding box given by two other points
Definition: math_vector_functions_common_impl.hpp:701
const number PI
Definition: math_constants.h:45
void GenVecCross< 2 >(MathVector< 2 > &result, const MathVector< 2 > &v_1, const MathVector< 2 > &v_2)
specialization of the "generalized vector product" in 2d.
Definition: math_vector_functions_common_impl.hpp:477
void GenVecCross< 3 >(MathVector< 3 > &result, const MathVector< 3 > &v_1, const MathVector< 3 > &v_2)
specialization of the "generalized vector product" in 3d.
Definition: math_vector_functions_common_impl.hpp:489
void VecElemProd(vector_t &vOut, const vector_t &v1, const vector_t &v2)
component-wise product: vOut_i = v1_i*v2_i
Definition: math_vector_functions_common_impl.hpp:651
bool VecAbsIsLess(const vector_t &v1, const vector_t &v2)
component-wise comparison of two vectors (in the absolute values)
Definition: math_vector_functions_common_impl.hpp:677
void VecElemSqrt(vector_t &vOut, const vector_t &v1)
component-wise square root:
Definition: math_vector_functions_common_impl.hpp:664
T value_type
Definition: sparsematrix_interface.h:2