isce3  0.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Basis.h
1 //-*- C++ -*-
2 //-*- coding: utf-8 -*-
3 //
4 // Author: Bryan V. Riel, Joshua Cohen
5 // Copyright 2017-2018
6 
7 #pragma once
8 
9 #include "forward.h"
10 
11 #include "Common.h"
12 #include "Vector.h"
13 
16 
17  public:
19  CUDA_HOSTDEV
20  Basis() {};
21 
23  CUDA_HOSTDEV
24  Basis(const Vec3& x0, const Vec3& x1, const Vec3& x2) :
25  _x0(x0), _x1(x1), _x2(x2) {}
26 
30  CUDA_HOSTDEV explicit Basis(const Vec3& p, const Vec3& v) {
31  const Vec3 n = -p.normalized();
32  const Vec3 c = n.cross(v).normalized();
33  const Vec3 t = c.cross(n).normalized();
34  _x0 = t;
35  _x1 = c;
36  _x2 = n;
37  }
38 
40  CUDA_HOSTDEV const Vec3& x0() const { return _x0; }
41 
43  CUDA_HOSTDEV const Vec3& x1() const { return _x1; }
44 
46  CUDA_HOSTDEV const Vec3& x2() const { return _x2; }
47 
49  CUDA_HOSTDEV void x0(const Vec3& x0) { _x0 = x0; }
50 
52  CUDA_HOSTDEV void x1(const Vec3& x1) { _x1 = x1; }
53 
55  CUDA_HOSTDEV void x2(const Vec3& x2) { _x2 = x2; }
56 
65  CUDA_HOSTDEV inline Vec3 project(Vec3& vec) {
66  return Vec3 { _x0.dot(vec),
67  _x1.dot(vec),
68  _x2.dot(vec) };
69  };
70 
79  inline void combine(cartesian_t &vec, cartesian_t &res) {
80  for(int ii =0; ii < 3; ii++) {
81  res[ii] = vec[0] * _x0[ii] + vec[1] * _x1[ii] + vec[2] * _x2[ii];
82  }
83  };
84 
85  private:
86  cartesian_t _x0;
87  cartesian_t _x1;
88  cartesian_t _x2;
89 };
CUDA_HOSTDEV Basis(const Vec3 &x0, const Vec3 &x1, const Vec3 &x2)
Constructor with basis vectors.
Definition: Basis.h:24
CUDA_HOSTDEV const Vec3 & x1() const
Return second basis vector.
Definition: Basis.h:43
CUDA_HOSTDEV void x1(const Vec3 &x1)
Set the second basis vector.
Definition: Basis.h:52
CUDA_HOSTDEV Vec3 project(Vec3 &vec)
Project a given vector onto basis.
Definition: Basis.h:65
CUDA_HOSTDEV const Vec3 & x0() const
Return first basis vector.
Definition: Basis.h:40
CUDA_HOSTDEV Basis()
Default constructor.
Definition: Basis.h:20
CUDA_HOSTDEV Basis(const Vec3 &p, const Vec3 &v)
Geocentric TCN constructor.
Definition: Basis.h:30
CUDA_HOSTDEV void x2(const Vec3 &x2)
Set the third basis vecot.
Definition: Basis.h:55
void combine(cartesian_t &vec, cartesian_t &res)
Combine the basis with given weights.
Definition: Basis.h:79
CUDA_HOSTDEV void x0(const Vec3 &x0)
Set the first basis vector.
Definition: Basis.h:49
Simple class to store three-dimensional basis vectors.
Definition: Basis.h:15
CUDA_HOSTDEV const Vec3 & x2() const
Return third basis vector.
Definition: Basis.h:46

Generated for ISCE3.0 by doxygen 1.8.5.