isce3 0.25.0
Loading...
Searching...
No Matches
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 <isce3/except/Error.h>
12
13#include "Common.h"
14#include "DenseMatrix.h"
15#include "Vector.h"
16
17namespace isce3 { namespace core {
18
20class Basis {
21
22public:
24 CUDA_HOSTDEV
25 Basis() : _x0 {1, 0, 0}, _x1 {0, 1, 0}, _x2 {0, 0, 1} {}
26
33 CUDA_HOST
34 Basis(const Vec3& x0, const Vec3& x1, const Vec3& x2, double tol = 1e-8)
35 : _x0(x0), _x1(x1), _x2(x2)
36 {
37 auto b = toRotationMatrix();
38 // Cast to array for elementwise abs() method.
39 Eigen::Array33d resid = b.transpose().dot(b) - Mat3::Identity();
40 if (not(resid.abs() < tol).all()) {
41 // throw means this ctor is CUDA_HOST only.
42 throw isce3::except::InvalidArgument(
43 ISCE_SRCINFO(), "Basis is not unitary/orthogonal");
44 }
45 }
46
50 CUDA_HOSTDEV explicit Basis(const Vec3& p, const Vec3& v)
51 {
52 const Vec3 n = -p.normalized();
53 const Vec3 c = n.cross(v).normalized();
54 const Vec3 t = c.cross(n).normalized();
55 _x0 = t;
56 _x1 = c;
57 _x2 = n;
58 }
59
61 CUDA_HOSTDEV const Vec3& x0() const { return _x0; }
62
64 CUDA_HOSTDEV const Vec3& x1() const { return _x1; }
65
67 CUDA_HOSTDEV const Vec3& x2() const { return _x2; }
68
70 CUDA_HOSTDEV void x0(const Vec3& x0) { _x0 = x0; }
71
73 CUDA_HOSTDEV void x1(const Vec3& x1) { _x1 = x1; }
74
76 CUDA_HOSTDEV void x2(const Vec3& x2) { _x2 = x2; }
77
86 CUDA_HOSTDEV inline Vec3 project(const Vec3& vec) const
87 {
88 return Vec3 {_x0.dot(vec), _x1.dot(vec), _x2.dot(vec)};
89 };
90
99 inline void combine(const Vec3& vec, Vec3& res) const
100 {
101 for (int ii = 0; ii < 3; ii++) {
102 res[ii] = vec[0] * _x0[ii] + vec[1] * _x1[ii] + vec[2] * _x2[ii];
103 }
104 };
105
106 // NOTE explicit operator Mat3() doesn't work due to Eigen weirdness,
107 // at least with GCC {8,9,10} and -std=c++17.
109 CUDA_HOSTDEV Mat3 toRotationMatrix() const
110 {
111 Mat3 out;
112 out.col(0) = _x0;
113 out.col(1) = _x1;
114 out.col(2) = _x2;
115 return out;
116 }
117
118private:
119 Vec3 _x0;
120 Vec3 _x1;
121 Vec3 _x2;
122};
123
130Vec3 velocityECI(const Vec3& position, const Vec3& velocityECF);
131
138Basis geodeticTCN(const Vec3& x, const Vec3& v, const Ellipsoid& ellipsoid);
139
148EulerAngles factoredYawPitchRoll(const Quaternion& q, const Vec3& x,
149 const Vec3& v, const Ellipsoid& ellipsoid);
150
159EulerAngles factoredYawPitchRoll(const Quaternion& q, const Vec3& x,
160 const Vec3& v);
161
162}} // namespace isce3::core
Simple class to store three-dimensional basis vectors.
Definition Basis.h:20
CUDA_HOSTDEV Basis()
Default to identity basis.
Definition Basis.h:25
Data structure to store Ellipsoid information.
Definition Ellipsoid.h:20
CUDA_HOSTDEV void x0(const Vec3 &x0)
Set the first basis vector.
Definition Basis.h:70
void combine(const Vec3 &vec, Vec3 &res) const
Combine the basis with given weights.
Definition Basis.h:99
CUDA_HOSTDEV const Vec3 & x2() const
Return third basis vector.
Definition Basis.h:67
CUDA_HOSTDEV Basis()
Default to identity basis.
Definition Basis.h:25
CUDA_HOSTDEV const Vec3 & x0() const
Return first basis vector.
Definition Basis.h:61
CUDA_HOSTDEV void x2(const Vec3 &x2)
Set the third basis vecot.
Definition Basis.h:76
CUDA_HOSTDEV Vec3 project(const Vec3 &vec) const
Project a given vector onto basis.
Definition Basis.h:86
CUDA_HOSTDEV const Vec3 & x1() const
Return second basis vector.
Definition Basis.h:64
CUDA_HOSTDEV void x1(const Vec3 &x1)
Set the second basis vector.
Definition Basis.h:73
CUDA_HOSTDEV Basis(const Vec3 &p, const Vec3 &v)
Geocentric TCN constructor.
Definition Basis.h:50
CUDA_HOST Basis(const Vec3 &x0, const Vec3 &x1, const Vec3 &x2, double tol=1e-8)
Constructor with basis vectors.
Definition Basis.h:34
CUDA_HOSTDEV Mat3 toRotationMatrix() const
Convert to matrix, vectors (x0, x1, x2) as columns (0, 1, 2).
Definition Basis.h:109
base interpolator is an abstract base class
Definition BinarySearchFunc.cpp:5

Generated for ISCE3.0 by doxygen 1.13.2.