acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
quadruple.h
1// Merge of estamira/particle/vec4 with geometry/sequence.h by
2// camilo on 2023-06-03 21:46 <3ThomasBorregaardSorensen!!
3#pragma once
4
5
6#include "acme/prototype/geometry/sequence.h"
7
8
9template < prototype_number NUMBER >
10struct quadruple_type :
11 public sequence_type < NUMBER, 4 >
12{
13
14
15 using UNIT_TYPE = NUMBER;
16// union
17// {
18// UNIT_TYPE m[4];
19//
20// struct
21// {
22// UNIT_TYPE x, y, z, w;
23// };
24//
25// struct
26// {
27// UNIT_TYPE r, g, b, a;
28// };
29// };
30
31
32 quadruple_type() {}
33 quadruple_type(no_initialize_t) : sequence_type < NUMBER, 2 >(no_initialize_t{}) {}
34 //point_type(nullptr_t) : sequence_type < NUMBER, 2 >(nullptr) {}
35
36// sequence_type(const sequence_type&) = default;
37
38// template <prototype_number T,
39// std::enable_if_t<T::SIZE == SIZE &&
40// std::is_same_v<typename T::COORDINATE, COORDINATE>, ::i32> = 0>
41 quadruple_type(UNIT_TYPE n)
42 {
43
44 this->set_all(n);
45
46 }
47// quadruple_type() {};
48// quadruple_type(::f32 f) { x = y = z = f; };
49// quadruple_type(const quadruple_type & v) = default;
50 //quadruple_type(quadruple_type && v) = default;
51 quadruple_type(UNIT_TYPE a, UNIT_TYPE b, UNIT_TYPE c = 0, UNIT_TYPE d = 0) :
52 sequence_type < UNIT_TYPE, 4 >(a, b, c, d)
53 {
54 }
55
56 template < prototype_number NUMBER1 >
57 quadruple_type(const sequence_type < NUMBER1, 4 > & sequence) :
58 sequence_type < UNIT_TYPE, 4 >(sequence)
59 {
60
61 }
62
63// quadruple_type(UNIT_TYPE a, UNIT_TYPE b, UNIT_TYPE c) { x = a; y = b; z = c; w = 0.0f; }
64// quadruple_type(UNIT_TYPE a, UNIT_TYPE b, UNIT_TYPE c, UNIT_TYPE d) { x = a; y = b; z = c; w = d; }
65// //~quadruple_type() = default;
66
67 //const UNIT_TYPE & x() const {return this->x;}
68 //UNIT_TYPE & x() {return this->x;}
69 //const UNIT_TYPE & y() const {return this->y;}
70 //UNIT_TYPE & y() {return this->y;}
71 //const UNIT_TYPE & z() const {return this->c();}
72 //UNIT_TYPE & z() {return this->c();}
73 //const UNIT_TYPE & w() const {return this->d();}
74 //UNIT_TYPE & w() {return this->d();}
75
76
77 quadruple_type & operator =(const quadruple_type & v) = default;
78
79 //inline void setAll(UNIT_TYPE f) { x = y = z = w = f; }
80
81 inline quadruple_type operator *(UNIT_TYPE n) const
82 {
83 return quadruple_type(this->x * n, this->y * n, this->z * n, this->w * n);
84 }
85
86 inline quadruple_type operator /(UNIT_TYPE n) const
87 {
88 return quadruple_type(this->x / n, this->y / n, this->z / n, this->w / n);
89 }
90
91 inline quadruple_type operator +(const quadruple_type & q) const
92 {
93 return quadruple_type(this->x + q.x, this->y + q.y, this->z + q.z, this->w + q.w);
94 }
95
96 inline quadruple_type operator -(const quadruple_type & t) const
97 {
98 return quadruple_type(this->x - t.x, this->y - t.y, this->z - t.z, this->w - t.w);
99 }
100
101 inline quadruple_type & operator +=(const quadruple_type & a)
102 {
103 this->add4(a);
104 return *this;
105 }
106
107 inline quadruple_type & operator -=(const quadruple_type & a)
108 {
109 this->sub4(a);
110 return *this;
111 }
112
113// inline UNIT_TYPE dot(const quadruple_type & q) const
114// {
115// return this->x * q.x + this->y * q.y + this->z * q.z + this->w * q.w;
116// }
117
118};
119
120
121using quadruple_f32 = quadruple_type < ::f32 >;
122using quadruple_f64 = quadruple_type < ::f64 >;
123
124
125template < prototype_number NUMBER1, prototype_number NUMBER2 >
126inline quadruple_type < largest_number < NUMBER1, NUMBER2 > > operator * (NUMBER1 n, const quadruple_type < NUMBER2 > & q)
127{
128
129 return quadruple_type < largest_number < NUMBER1, NUMBER2 > >(n * q.x, n * q.y, n * q.z, n * q.w);
130}
Definition _tags.h:5