PeriDyno 1.0.0
Loading...
Searching...
No Matches
Vector4D.h
Go to the documentation of this file.
1#pragma once
2#include <glm/vec4.hpp>
3#include <iostream>
4
5#include "VectorBase.h"
6
7namespace dyno {
8
9 template <typename T, int Dim> class SquareMatrix;
10
11 /*
12 * Vector<T,4> are defined for C++ fundamental integer types and floating-point types
13 */
14
15 template <typename T>
16 class Vector<T, 4>
17 {
18 public:
19 typedef T VarType;
20
21 DYN_FUNC Vector();
22 DYN_FUNC explicit Vector(T);
23 DYN_FUNC Vector(T x, T y, T z, T w);
24 DYN_FUNC Vector(const Vector<T, 4>&);
25 DYN_FUNC ~Vector();
26
27 DYN_FUNC static int dims() { return 4; }
28
29 DYN_FUNC T& operator[] (unsigned int);
30 DYN_FUNC const T& operator[] (unsigned int) const;
31
32 DYN_FUNC const Vector<T, 4> operator+ (const Vector<T, 4> &) const;
33 DYN_FUNC Vector<T, 4>& operator+= (const Vector<T, 4> &);
34 DYN_FUNC const Vector<T, 4> operator- (const Vector<T, 4> &) const;
35 DYN_FUNC Vector<T, 4>& operator-= (const Vector<T, 4> &);
36 DYN_FUNC const Vector<T, 4> operator* (const Vector<T, 4> &) const;
37 DYN_FUNC Vector<T, 4>& operator*= (const Vector<T, 4> &);
38 DYN_FUNC const Vector<T, 4> operator/ (const Vector<T, 4> &) const;
39 DYN_FUNC Vector<T, 4>& operator/= (const Vector<T, 4> &);
40
41 DYN_FUNC Vector<T, 4>& operator= (const Vector<T, 4> &);
42
43 DYN_FUNC bool operator== (const Vector<T, 4> &) const;
44 DYN_FUNC bool operator!= (const Vector<T, 4> &) const;
45
46 DYN_FUNC const Vector<T, 4> operator+ (T) const;
47 DYN_FUNC const Vector<T, 4> operator- (T) const;
48 DYN_FUNC const Vector<T, 4> operator* (T) const;
49 DYN_FUNC const Vector<T, 4> operator/ (T) const;
50
51 DYN_FUNC Vector<T, 4>& operator+= (T);
52 DYN_FUNC Vector<T, 4>& operator-= (T);
53 DYN_FUNC Vector<T, 4>& operator*= (T);
54 DYN_FUNC Vector<T, 4>& operator/= (T);
55
56 DYN_FUNC const Vector<T, 4> operator - (void) const;
57
58 DYN_FUNC T norm() const;
59 DYN_FUNC T normSquared() const;
60 DYN_FUNC Vector<T, 4>& normalize();
61 DYN_FUNC T dot(const Vector<T, 4>&) const;
62 // DYN_FUNC const SquareMatrix<T,4> outerProduct(const Vector<T,4>&) const;
63
64 DYN_FUNC Vector<T, 4> minimum(const Vector<T, 4> &) const;
65 DYN_FUNC Vector<T, 4> maximum(const Vector<T, 4> &) const;
66
67 DYN_FUNC T* getDataPtr() { return &data_.x; }
68
69 friend std::ostream& operator<<(std::ostream &out, const Vector<T, 4>& vec)
70 {
71 out << "(" << vec[0] << ", " << vec[1] << ", " << vec[2] << ", " << vec[3] << ")";
72 return out;
73 }
74 public:
75 union
76 {
77 glm::tvec4<T> data_; //default: zero vector
78 struct { T x, y, z, w; };
79 };
80
81 };
82
83 template class Vector<float, 4>;
84 template class Vector<double, 4>;
85 //convenient typedefs
88
89} //end of namespace dyno
90
91#include "Vector4D.inl"
static DYN_FUNC int dims()
Definition Vector4D.h:27
DYN_FUNC Vector()
Definition Vector4D.inl:7
friend std::ostream & operator<<(std::ostream &out, const Vector< T, 4 > &vec)
Definition Vector4D.h:69
glm::tvec4< T > data_
Definition Vector4D.h:77
DYN_FUNC T * getDataPtr()
Definition Vector4D.h:67
DYN_FUNC ~Vector()
Definition VectorBase.h:27
DYN_FUNC Vector()
Definition VectorBase.h:26
#define T(t)
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
DYN_FUNC T dot(Vector< T, 2 > const &U, Vector< T, 2 > const &V)
Definition SimpleMath.h:199
Vector< double, 4 > Vec4d
Definition Vector4D.h:87
Vector< float, 4 > Vec4f
Definition Vector4D.h:86
DYN_FUNC const Complex< T > operator/(S scale, const Complex< T > &complex)
Definition Complex.inl:253
DYN_FUNC T minimum(const T &v0, const T &v1)
Definition SimpleMath.h:120
DYN_FUNC const Complex< T > operator*(S scale, const Complex< T > &complex)
Definition Complex.inl:247
DYN_FUNC bool operator==(const priority_queue< T, Container, Compare > &a, const priority_queue< T, Container, Compare > &b)
DYN_FUNC bool operator!=(const priority_queue< T, Container, Compare > &a, const priority_queue< T, Container, Compare > &b)
DYN_FUNC T maximum(const T &v0, const T &v1)
Definition SimpleMath.h:160
DYN_FUNC const Complex< T > operator-(S scale, const Complex< T > &complex)
Definition Complex.inl:241
DYN_FUNC const Complex< T > operator+(S scale, const Complex< T > &complex)
Definition Complex.inl:235