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