NumCpp  2.8.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
hat.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #include <string>
31 
34 #include "NumCpp/NdArray.hpp"
35 #include "NumCpp/Vector/Vec3.hpp"
36 
37 namespace nc
38 {
39  namespace linalg
40  {
41  //============================================================================
42  // Method Description:
50  template<typename dtype>
51  NdArray<dtype> hat(dtype inX, dtype inY, dtype inZ)
52  {
54 
55  NdArray<dtype> returnArray(3);
56  returnArray(0, 0) = 0.0;
57  returnArray(0, 1) = -inZ;
58  returnArray(0, 2) = inY;
59  returnArray(1, 0) = inZ;
60  returnArray(1, 1) = 0.0;
61  returnArray(1, 2) = -inX;
62  returnArray(2, 0) = -inY;
63  returnArray(2, 1) = inX;
64  returnArray(2, 2) = 0.0;
65 
66  return returnArray;
67  }
68 
69  //============================================================================
70  // Method Description:
76  template<typename dtype>
78  {
80 
81  if (inVec.size() != 3)
82  {
83  THROW_INVALID_ARGUMENT_ERROR("input vector must be a length 3 cartesian vector.");
84  }
85 
86  return hat(inVec[0], inVec[1], inVec[2]);
87  }
88 
89  //============================================================================
90  // Method Description:
96  inline NdArray<double> hat(const Vec3& inVec)
97  {
98  return hat(inVec.x, inVec.y, inVec.z);
99  }
100  } // namespace linalg
101 } // 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:4289
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:51
Definition: Coordinate.hpp:45