half_float_vector.h
1 /*
2 ** UICore
3 ** Copyright (c) 1997-2015 The UICore Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries UICore may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 ** Mark Page
28 */
29 
30 #pragma once
31 
32 #include "half_float.h"
33 #include "vec2.h"
34 #include "vec3.h"
35 #include "vec4.h"
36 #include "point.h"
37 
38 namespace uicore
39 {
40  class Vec2hf;
41  class Vec3hf;
42  class Vec4hf;
43 
45  class Vec2hf
46  {
47  public:
50 
51  Vec2hf() : x(), y() { }
52 
53  explicit Vec2hf(const HalfFloat &scalar) : x(scalar), y(scalar) { }
54  explicit Vec2hf(const Vec3hf &copy);
55  explicit Vec2hf(const Vec4hf &copy);
56  explicit Vec2hf(const HalfFloat &p1, const HalfFloat &p2) : x(p1), y(p2) { }
57  explicit Vec2hf(const HalfFloat *array_xy) : x(array_xy[0]), y(array_xy[1]) { }
58 
59  explicit Vec2hf(float scalar) : x(scalar), y(scalar) { }
60  explicit Vec2hf(const Vec3f &copy) : x(copy.x), y(copy.y) { }
61  explicit Vec2hf(const Vec4f &copy) : x(copy.x), y(copy.y) { }
62  explicit Vec2hf(float p1, float p2) : x(p1), y(p2) { }
63  explicit Vec2hf(float *array_xy) : x(array_xy[0]), y(array_xy[1]) { }
64  explicit Vec2hf(const Pointx<int> &point) : x(static_cast<float> (point.x)), y(static_cast<float> (point.y)) { }
65  explicit Vec2hf(const Pointx<float> &point) : x(point.x), y(point.y) { }
66  explicit Vec2hf(const Pointx<double> &point) : x(static_cast<float> (point.x)), y(static_cast<float> (point.y)) { }
67 
68  Vec2hf(const Vec2hf &copy) : x(copy.x), y(copy.y) { }
69  Vec2hf(const Vec2d &copy) : x((float)copy.x), y((float)copy.y) { }
70  Vec2hf(const Vec2f &copy) : x(copy.x), y(copy.y) { }
71  Vec2hf(const Vec2i &copy) : x((float)copy.x), y((float)copy.y) { }
72 
73  public:
74  operator Vec2f() const { return to_float(); }
75  Vec2f to_float() const { return Vec2f((float)x, (float)y); }
76  };
77 
79  class Vec3hf
80  {
81  public:
85 
86  Vec3hf() : x(), y(), z() { }
87  explicit Vec3hf(const HalfFloat &scalar) : x(scalar), y(scalar), z(scalar) { }
88  explicit Vec3hf(const Vec2hf &copy, const HalfFloat &p3) : x(copy.x), y(copy.y), z(p3) { }
89  explicit Vec3hf(const Vec4hf &copy);
90  explicit Vec3hf(const HalfFloat &p1, const HalfFloat &p2, const HalfFloat &p3) : x(p1), y(p2), z(p3) { }
91  explicit Vec3hf(const HalfFloat *array_xyz) : x(array_xyz[0]), y(array_xyz[1]), z(array_xyz[2]) { }
92 
93  explicit Vec3hf(float scalar) : x(scalar), y(scalar), z(scalar) { }
94  explicit Vec3hf(const Vec2f &copy, float p3) : x(copy.x), y(copy.y), z(p3) { }
95  explicit Vec3hf(const Vec4f &copy) : x(copy.x), y(copy.y), z(copy.z) { }
96  explicit Vec3hf(float p1, float p2, float p3) : x(p1), y(p2), z(p3) { }
97  explicit Vec3hf(const float *array_xyz) : x(array_xyz[0]), y(array_xyz[1]), z(array_xyz[2]){ }
98 
99  Vec3hf(const Vec3hf &copy) : x(copy.x), y(copy.y), z(copy.z) { }
100  Vec3hf(const Vec3d &copy) : x((float)copy.x), y((float)copy.y), z((float)copy.z) { }
101  Vec3hf(const Vec3f &copy) : x(copy.x), y(copy.y), z(copy.z) { }
102  Vec3hf(const Vec3i &copy) : x((float)copy.x), y((float)copy.y), z((float)copy.z) { }
103 
104  public:
105  operator Vec3f() const { return to_float(); }
106  Vec3f to_float() const { return Vec3f((float)x, (float)y, (float)z); }
107  };
108 
110  class Vec4hf
111  {
112  public:
117 
118  Vec4hf() : x(), y(), z(), w() { }
119  explicit Vec4hf(const Vec4f &copy) : x(copy.x), y(copy.y), z(copy.z), w(copy.w) { }
120 
121  explicit Vec4hf(const HalfFloat &scalar) : x(scalar), y(scalar), z(scalar), w(scalar) { }
122  explicit Vec4hf(const Vec2hf &copy, const HalfFloat &p3, const HalfFloat &p4) : x(copy.x), y(copy.y), z(p3), w(p4) { }
123  explicit Vec4hf(const Vec2hf &copy, const Vec2hf &copy34) : x(copy.x), y(copy.y), z(copy34.x), w(copy34.y) { }
124  explicit Vec4hf(const Vec3hf &copy, const HalfFloat &p4) : x(copy.x), y(copy.y), z(copy.z), w(p4) { }
125  explicit Vec4hf(const HalfFloat &p1, const HalfFloat &p2, const HalfFloat &p3, const HalfFloat &p4) : x(p1), y(p2), z(p3), w(p4) { }
126  explicit Vec4hf(const HalfFloat &p1, const HalfFloat &p2, const Vec2hf &copy34) : x(p1), y(p2), z(copy34.x), w(copy34.y) { }
127  explicit Vec4hf(const HalfFloat *array_xyzw) : x(array_xyzw[0]), y(array_xyzw[1]), z(array_xyzw[2]), w(array_xyzw[3]) { }
128 
129  explicit Vec4hf(float scalar) : x(scalar), y(scalar), z(scalar), w(scalar) { }
130  explicit Vec4hf(const Vec2f &copy, float p3, float p4) : x(copy.x), y(copy.y), z(p3), w(p4) { }
131  explicit Vec4hf(const Vec2f &copy, const Vec2f &copy34) : x(copy.x), y(copy.y), z(copy34.x), w(copy34.y) { }
132  explicit Vec4hf(const Vec3f &copy, float p4) : x(copy.x), y(copy.y), z(copy.z), w(p4) { }
133  explicit Vec4hf(float p1, float p2, float p3, float p4) : x(p1), y(p2), z(p3), w(p4) { }
134  explicit Vec4hf(float p1, float p2, const Vec2f &copy34) : x(p1), y(p2), z(copy34.x), w(copy34.y) { }
135  explicit Vec4hf(const float *array_xyzw) : x(array_xyzw[0]), y(array_xyzw[1]), z(array_xyzw[2]), w(array_xyzw[3]) { }
136 
137  public:
138  operator Vec4f() const { return to_float(); }
139  Vec4f to_float() const { return Vec4f((float)x, (float)y, (float)z, (float)w); }
140  };
141 
142  inline Vec2hf::Vec2hf(const Vec3hf &copy) : x(copy.x), y(copy.y) {}
143  inline Vec2hf::Vec2hf(const Vec4hf &copy) : x(copy.x), y(copy.y) {}
144 
145  inline Vec3hf::Vec3hf(const Vec4hf &copy) : x(copy.x), y(copy.y), z(copy.z) {}
146 }
Vec4hf(const Vec2f &copy, const Vec2f &copy34)
Definition: half_float_vector.h:131
Vec4hf(float p1, float p2, float p3, float p4)
Definition: half_float_vector.h:133
Vec2hf(const Vec2d &copy)
Definition: half_float_vector.h:69
Vec4hf(const Vec4f &copy)
Definition: half_float_vector.h:119
Vec2hf(const Pointx< float > &point)
Definition: half_float_vector.h:65
Definition: half_float.h:33
Vec2hf(const Vec2hf &copy)
Definition: half_float_vector.h:68
Vec2hf(const HalfFloat &scalar)
Definition: half_float_vector.h:53
Vec2hf()
Definition: half_float_vector.h:51
Vec3hf(const HalfFloat *array_xyz)
Definition: half_float_vector.h:91
Vec4f to_float() const
Definition: half_float_vector.h:139
Vec3f to_float() const
Definition: half_float_vector.h:106
Vec2hf(const HalfFloat *array_xy)
Definition: half_float_vector.h:57
Vec3< float > Vec3f
Definition: vec3.h:410
HalfFloat y
Definition: half_float_vector.h:83
HalfFloat y
Definition: half_float_vector.h:49
Vec2hf(float scalar)
Definition: half_float_vector.h:59
Vec4hf(const Vec2f &copy, float p3, float p4)
Definition: half_float_vector.h:130
HalfFloat x
Definition: half_float_vector.h:82
Vec3hf(const Vec2f &copy, float p3)
Definition: half_float_vector.h:94
Vec2f to_float() const
Definition: half_float_vector.h:75
Vec4hf()
Definition: half_float_vector.h:118
Vec4hf(const Vec2hf &copy, const HalfFloat &p3, const HalfFloat &p4)
Definition: half_float_vector.h:122
4D half-float vector
Definition: half_float_vector.h:110
3D half-float vector
Definition: half_float_vector.h:79
2D half-float vector
Definition: half_float_vector.h:45
Vec2hf(const Vec2f &copy)
Definition: half_float_vector.h:70
Vec4hf(const HalfFloat &p1, const HalfFloat &p2, const HalfFloat &p3, const HalfFloat &p4)
Definition: half_float_vector.h:125
HalfFloat y
Definition: half_float_vector.h:114
Vec4hf(const Vec2hf &copy, const Vec2hf &copy34)
Definition: half_float_vector.h:123
Vec4< float > Vec4f
Definition: vec4.h:386
Vec2hf(float *array_xy)
Definition: half_float_vector.h:63
Vec3hf(const HalfFloat &scalar)
Definition: half_float_vector.h:87
Vec3hf(const Vec3i &copy)
Definition: half_float_vector.h:102
Vec3hf(const HalfFloat &p1, const HalfFloat &p2, const HalfFloat &p3)
Definition: half_float_vector.h:90
Vec2hf(const Vec2i &copy)
Definition: half_float_vector.h:71
Vec3hf(const Vec3f &copy)
Definition: half_float_vector.h:101
Vec2hf(const Vec3f &copy)
Definition: half_float_vector.h:60
HalfFloat w
Definition: half_float_vector.h:116
Vec3hf(const Vec4f &copy)
Definition: half_float_vector.h:95
Vec4hf(float p1, float p2, const Vec2f &copy34)
Definition: half_float_vector.h:134
Vec2hf(const Pointx< double > &point)
Definition: half_float_vector.h:66
Vec2< float > Vec2f
Definition: vec2.h:419
Vec2hf(float p1, float p2)
Definition: half_float_vector.h:62
HalfFloat x
Definition: half_float_vector.h:113
Vec4hf(const HalfFloat &p1, const HalfFloat &p2, const Vec2hf &copy34)
Definition: half_float_vector.h:126
Vec3hf(const Vec3hf &copy)
Definition: half_float_vector.h:99
Vec3hf(const float *array_xyz)
Definition: half_float_vector.h:97
Vec2hf(const Vec4f &copy)
Definition: half_float_vector.h:61
Vec3hf(const Vec2hf &copy, const HalfFloat &p3)
Definition: half_float_vector.h:88
Vec4hf(float scalar)
Definition: half_float_vector.h:129
HalfFloat z
Definition: half_float_vector.h:84
HalfFloat z
Definition: half_float_vector.h:115
Vec2hf(const HalfFloat &p1, const HalfFloat &p2)
Definition: half_float_vector.h:56
Vec3hf(const Vec3d &copy)
Definition: half_float_vector.h:100
Vec2hf(const Pointx< int > &point)
Definition: half_float_vector.h:64
Vec4hf(const HalfFloat *array_xyzw)
Definition: half_float_vector.h:127
Vec4hf(const HalfFloat &scalar)
Definition: half_float_vector.h:121
Vec3hf(float p1, float p2, float p3)
Definition: half_float_vector.h:96
HalfFloat x
Definition: half_float_vector.h:48
Vec4hf(const Vec3f &copy, float p4)
Definition: half_float_vector.h:132
Vec4hf(const float *array_xyzw)
Definition: half_float_vector.h:135
Definition: Application/application.h:35
Vec4hf(const Vec3hf &copy, const HalfFloat &p4)
Definition: half_float_vector.h:124
Vec3hf(float scalar)
Definition: half_float_vector.h:93
Vec3hf()
Definition: half_float_vector.h:86