Titan
v1.0
A high-performance CUDA-based physics simulation sandbox for robotics, physics, and reinforcement learning.
|
Go to the documentation of this file.
13 #define CUDA_CALLABLE_MEMBER __host__ __device__
15 #define CUDA_CALLABLE_MEMBER
19 #define CUDA_DEVICE __device__
25 #include <cuda_runtime.h>
88 return Vec(-data[0], -data[1], -data[2]);
92 if (n < 0 || n >= 3) {
93 printf(
"%s\n",
"Out of bounds!");
101 if (n < 0 || n >= 3) {
102 printf(
"%s\n",
"Out of bounds!");
110 return Vec(v1.data[0] + v2.data[0], v1.data[1] + v2.data[1], v1.data[2] + v2.data[2]);
114 return Vec(v1.data[0] - v2.data[0], v1.data[1] - v2.data[1], v1.data[2] - v2.data[2]);
118 return Vec(v.data[0] * x, v.data[1] * x, v.data[2] * x);
126 return (v1[0] == v2[0] && v1[1] == v2[1] && v1[2] == v2[2]);
130 return Vec(v1.data[0] * v2.data[0], v1.data[1] * v2.data[1], v1.data[2] * v2.data[2]);
134 return Vec(v.data[0] / x, v.data[1] / x, v.data[2] / x);
138 return Vec(v1.data[0] / v2.data[0], v1.data[1] / v2.data[1], v1.data[2] / v2.data[2]);
142 return strm <<
"(" << v[0] <<
", " << v[1] <<
", " << v[2] <<
")";
146 printf(
"(%3f, %3f, %3f)\n", data[0], data[1], data[2]);
150 return sqrt(pow(data[0], 2) + pow(data[1], 2) + pow(data[2], 2));
154 return data[0] + data[1] + data[2];
158 return *
this /
norm();
162 double data[3] = { 0 };
CUDA_CALLABLE_MEMBER Vec & operator=(const Vec &v)
Definition: vec.h:59
CUDA_CALLABLE_MEMBER double norm() const
Definition: vec.h:149
CUDA_CALLABLE_MEMBER double dot(const Vec &a, const Vec &b)
CUDA_CALLABLE_MEMBER void print()
Definition: vec.h:145
CUDA_CALLABLE_MEMBER Vec operator-() const
Definition: vec.h:87
CUDA_CALLABLE_MEMBER Vec(const Vec &v)
Definition: vec.h:41
friend std::ostream & operator<<(std::ostream &strm, const Vec &v)
Definition: vec.h:141
CUDA_CALLABLE_MEMBER double & operator[](int n)
Definition: vec.h:91
CUDA_CALLABLE_MEMBER Vec()
Definition: vec.h:35
#define CUDA_DEVICE
Definition: vec.h:21
CUDA_DEVICE void atomicVecAdd(const Vec &v)
CUDA_CALLABLE_MEMBER friend Vec operator*(const double x, const Vec &v)
Definition: vec.h:117
CUDA_CALLABLE_MEMBER double sum() const
Definition: vec.h:153
CUDA_CALLABLE_MEMBER friend Vec operator+(const Vec &v1, const Vec &v2)
Definition: vec.h:109
CUDA_CALLABLE_MEMBER Vec & operator+=(const Vec &v)
Definition: vec.h:71
CUDA_CALLABLE_MEMBER friend Vec operator-(const Vec &v1, const Vec &v2)
Definition: vec.h:113
CUDA_CALLABLE_MEMBER friend Vec operator*(const Vec &v, const double x)
Definition: vec.h:121
#define CUDA_CALLABLE_MEMBER
Definition: vec.h:15
CUDA_CALLABLE_MEMBER Vec normalize() const
Definition: vec.h:157
CUDA_CALLABLE_MEMBER friend Vec operator/(const Vec &v, const double x)
Definition: vec.h:133
CUDA_CALLABLE_MEMBER friend bool operator==(const Vec &v1, const Vec &v2)
Definition: vec.h:125
CUDA_CALLABLE_MEMBER Vec & operator-=(const Vec &v)
Definition: vec.h:78
CUDA_CALLABLE_MEMBER friend Vec operator*(const Vec &v1, const Vec &v2)
Definition: vec.h:129
CUDA_CALLABLE_MEMBER Vec(double x, double y, double z)
Definition: vec.h:47
CUDA_CALLABLE_MEMBER Vec(const std::vector< double > &v)
Definition: vec.h:53
CUDA_CALLABLE_MEMBER friend Vec operator/(const Vec &v1, const Vec &v2)
Definition: vec.h:137
CUDA_CALLABLE_MEMBER Vec cross(const Vec &v1, const Vec &v2)