NumCpp  2.4.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 
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
StaticAsserts.hpp
nc::Vec3::y
double y
Definition: Vec3.hpp:54
Error.hpp
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
nc::linalg::hat
NdArray< dtype > hat(dtype inX, dtype inY, dtype inZ)
Definition: hat.hpp:52
nc::Vec3::z
double z
Definition: Vec3.hpp:55
nc::NdArray< dtype >
NdArray.hpp
Vec3.hpp
nc::NdArray::size
size_type size() const noexcept
Definition: NdArrayCore.hpp:4370
nc
Definition: Coordinate.hpp:44
THROW_INVALID_ARGUMENT_ERROR
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
nc::Vec3::x
double x
Definition: Vec3.hpp:53
nc::Vec3
Holds a 3D vector.
Definition: Vec3.hpp:49