NumCpp  2.6.2
A Templatized Header Only C++ Implementation of the Python NumPy Library
hat.hpp
Go to the documentation of this file.
1 
28 #pragma once
29 
32 #include "NumCpp/NdArray.hpp"
33 #include "NumCpp/Vector/Vec3.hpp"
34 
35 #include <string>
36 
37 namespace nc
38 {
39  namespace linalg
40  {
41  //============================================================================
42  // Method Description:
51  template<typename dtype>
52  NdArray<dtype> hat(dtype inX, dtype inY, dtype inZ)
53  {
55 
56  NdArray<dtype> returnArray(3);
57  returnArray(0, 0) = 0.0;
58  returnArray(0, 1) = -inZ;
59  returnArray(0, 2) = inY;
60  returnArray(1, 0) = inZ;
61  returnArray(1, 1) = 0.0;
62  returnArray(1, 2) = -inX;
63  returnArray(2, 0) = -inY;
64  returnArray(2, 1) = inX;
65  returnArray(2, 2) = 0.0;
66 
67  return returnArray;
68  }
69 
70  //============================================================================
71  // Method Description:
79  template<typename dtype>
81  {
83 
84  if (inVec.size() != 3)
85  {
86  THROW_INVALID_ARGUMENT_ERROR("input vector must be a length 3 cartesian vector.");
87  }
88 
89  return hat(inVec[0], inVec[1], inVec[2]);
90  }
91 
92  //============================================================================
93  // Method Description:
101  inline NdArray<double> hat(const Vec3& inVec)
102  {
103  return hat(inVec.x, inVec.y, inVec.z);
104  }
105  } // namespace linalg
106 } // namespace nc
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
size_type size() const noexcept
Definition: NdArrayCore.hpp:4497
Holds a 3D vector.
Definition: Vec3.hpp:50
double z
Definition: Vec3.hpp:55
double x
Definition: Vec3.hpp:53
double y
Definition: Vec3.hpp:54
NdArray< dtype > hat(dtype inX, dtype inY, dtype inZ)
Definition: hat.hpp:52
Definition: Coordinate.hpp:45