half_float_vector.h
1/*
2** ClanLib SDK
3** Copyright (c) 1997-2020 The ClanLib 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 ClanLib 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
38namespace clan
39{
42
43 class Vec2hf;
44 class Vec3hf;
45 class Vec4hf;
46
48 class Vec2hf
49 {
50 public:
53
54 Vec2hf() : x(), y() { }
55
56 explicit Vec2hf(const HalfFloat &scalar) : x(scalar), y(scalar) { }
57 explicit Vec2hf(const Vec3hf &copy);
58 explicit Vec2hf(const Vec4hf &copy);
59 explicit Vec2hf(const HalfFloat &p1, const HalfFloat &p2) : x(p1), y(p2) { }
60 explicit Vec2hf(const HalfFloat *array_xy) : x(array_xy[0]), y(array_xy[1]) { }
61
62 explicit Vec2hf(float scalar) : x(scalar), y(scalar) { }
63 explicit Vec2hf(const Vec3f &copy) : x(copy.x), y(copy.y) { }
64 explicit Vec2hf(const Vec4f &copy) : x(copy.x), y(copy.y) { }
65 explicit Vec2hf(float p1, float p2) : x(p1), y(p2) { }
66 explicit Vec2hf(float *array_xy) : x(array_xy[0]), y(array_xy[1]) { }
67 explicit Vec2hf(const Pointx<int> &point) : x(static_cast<float> (point.x)), y(static_cast<float> (point.y)) { }
68 explicit Vec2hf(const Pointx<float> &point) : x(point.x), y(point.y) { }
69 explicit Vec2hf(const Pointx<double> &point) : x(static_cast<float> (point.x)), y(static_cast<float> (point.y)) { }
70
71 Vec2hf(const Vec2hf &copy) : x(copy.x), y(copy.y) { }
72 Vec2hf(const Vec2d &copy) : x((float)copy.x), y((float)copy.y) { }
73 Vec2hf(const Vec2f &copy) : x(copy.x), y(copy.y) { }
74 Vec2hf(const Vec2i &copy) : x((float)copy.x), y((float)copy.y) { }
75
76 public:
77 operator Vec2f() const { return to_float(); }
78 Vec2f to_float() const { return Vec2f((float)x, (float)y); }
79 };
80
82 class Vec3hf
83 {
84 public:
88
89 Vec3hf() : x(), y(), z() { }
90 explicit Vec3hf(const HalfFloat &scalar) : x(scalar), y(scalar), z(scalar) { }
91 explicit Vec3hf(const Vec2hf &copy, const HalfFloat &p3) : x(copy.x), y(copy.y), z(p3) { }
92 explicit Vec3hf(const Vec4hf &copy);
93 explicit Vec3hf(const HalfFloat &p1, const HalfFloat &p2, const HalfFloat &p3) : x(p1), y(p2), z(p3) { }
94 explicit Vec3hf(const HalfFloat *array_xyz) : x(array_xyz[0]), y(array_xyz[1]), z(array_xyz[2]) { }
95
96 explicit Vec3hf(float scalar) : x(scalar), y(scalar), z(scalar) { }
97 explicit Vec3hf(const Vec2f &copy, float p3) : x(copy.x), y(copy.y), z(p3) { }
98 explicit Vec3hf(const Vec4f &copy) : x(copy.x), y(copy.y), z(copy.z) { }
99 explicit Vec3hf(float p1, float p2, float p3) : x(p1), y(p2), z(p3) { }
100 explicit Vec3hf(const float *array_xyz) : x(array_xyz[0]), y(array_xyz[1]), z(array_xyz[2]){ }
101
102 Vec3hf(const Vec3hf &copy) : x(copy.x), y(copy.y), z(copy.z) { }
103 Vec3hf(const Vec3d &copy) : x((float)copy.x), y((float)copy.y), z((float)copy.z) { }
104 Vec3hf(const Vec3f &copy) : x(copy.x), y(copy.y), z(copy.z) { }
105 Vec3hf(const Vec3i &copy) : x((float)copy.x), y((float)copy.y), z((float)copy.z) { }
106
107 public:
108 operator Vec3f() const { return to_float(); }
109 Vec3f to_float() const { return Vec3f((float)x, (float)y, (float)z); }
110 };
111
113 class Vec4hf
114 {
115 public:
120
121 Vec4hf() : x(), y(), z(), w() { }
122 explicit Vec4hf(const Vec4f &copy) : x(copy.x), y(copy.y), z(copy.z), w(copy.w) { }
123
124 explicit Vec4hf(const HalfFloat &scalar) : x(scalar), y(scalar), z(scalar), w(scalar) { }
125 explicit Vec4hf(const Vec2hf &copy, const HalfFloat &p3, const HalfFloat &p4) : x(copy.x), y(copy.y), z(p3), w(p4) { }
126 explicit Vec4hf(const Vec2hf &copy, const Vec2hf &copy34) : x(copy.x), y(copy.y), z(copy34.x), w(copy34.y) { }
127 explicit Vec4hf(const Vec3hf &copy, const HalfFloat &p4) : x(copy.x), y(copy.y), z(copy.z), w(p4) { }
128 explicit Vec4hf(const HalfFloat &p1, const HalfFloat &p2, const HalfFloat &p3, const HalfFloat &p4) : x(p1), y(p2), z(p3), w(p4) { }
129 explicit Vec4hf(const HalfFloat &p1, const HalfFloat &p2, const Vec2hf &copy34) : x(p1), y(p2), z(copy34.x), w(copy34.y) { }
130 explicit Vec4hf(const HalfFloat *array_xyzw) : x(array_xyzw[0]), y(array_xyzw[1]), z(array_xyzw[2]), w(array_xyzw[3]) { }
131
132 explicit Vec4hf(float scalar) : x(scalar), y(scalar), z(scalar), w(scalar) { }
133 explicit Vec4hf(const Vec2f &copy, float p3, float p4) : x(copy.x), y(copy.y), z(p3), w(p4) { }
134 explicit Vec4hf(const Vec2f &copy, const Vec2f &copy34) : x(copy.x), y(copy.y), z(copy34.x), w(copy34.y) { }
135 explicit Vec4hf(const Vec3f &copy, float p4) : x(copy.x), y(copy.y), z(copy.z), w(p4) { }
136 explicit Vec4hf(float p1, float p2, float p3, float p4) : x(p1), y(p2), z(p3), w(p4) { }
137 explicit Vec4hf(float p1, float p2, const Vec2f &copy34) : x(p1), y(p2), z(copy34.x), w(copy34.y) { }
138 explicit Vec4hf(const float *array_xyzw) : x(array_xyzw[0]), y(array_xyzw[1]), z(array_xyzw[2]), w(array_xyzw[3]) { }
139
140 public:
141 operator Vec4f() const { return to_float(); }
142 Vec4f to_float() const { return Vec4f((float)x, (float)y, (float)z, (float)w); }
143 };
144
145 inline Vec2hf::Vec2hf(const Vec3hf &copy) : x(copy.x), y(copy.y) {}
146 inline Vec2hf::Vec2hf(const Vec4hf &copy) : x(copy.x), y(copy.y) {}
147
148 inline Vec3hf::Vec3hf(const Vec4hf &copy) : x(copy.x), y(copy.y), z(copy.z) {}
149
151}
Definition: half_float.h:37
2D (x,y) point structure.
Definition: point.h:52
2D half-float vector
Definition: half_float_vector.h:49
Vec2hf(const Pointx< int > &point)
Definition: half_float_vector.h:67
Vec2hf(const Pointx< double > &point)
Definition: half_float_vector.h:69
Vec2hf(const HalfFloat &p1, const HalfFloat &p2)
Definition: half_float_vector.h:59
Vec2hf(float p1, float p2)
Definition: half_float_vector.h:65
Vec2hf()
Definition: half_float_vector.h:54
Vec2hf(float scalar)
Definition: half_float_vector.h:62
Vec2f to_float() const
Definition: half_float_vector.h:78
Vec2hf(const Pointx< float > &point)
Definition: half_float_vector.h:68
Vec2hf(const Vec2f &copy)
Definition: half_float_vector.h:73
HalfFloat x
Definition: half_float_vector.h:51
Vec2hf(float *array_xy)
Definition: half_float_vector.h:66
Vec2hf(const Vec2hf &copy)
Definition: half_float_vector.h:71
Vec2hf(const Vec2d &copy)
Definition: half_float_vector.h:72
Vec2hf(const Vec4f &copy)
Definition: half_float_vector.h:64
Vec2hf(const HalfFloat *array_xy)
Definition: half_float_vector.h:60
Vec2hf(const Vec2i &copy)
Definition: half_float_vector.h:74
HalfFloat y
Definition: half_float_vector.h:52
Vec2hf(const Vec3f &copy)
Definition: half_float_vector.h:63
Vec2hf(const HalfFloat &scalar)
Definition: half_float_vector.h:56
3D half-float vector
Definition: half_float_vector.h:83
HalfFloat x
Definition: half_float_vector.h:85
Vec3hf(const HalfFloat &p1, const HalfFloat &p2, const HalfFloat &p3)
Definition: half_float_vector.h:93
Vec3hf(float p1, float p2, float p3)
Definition: half_float_vector.h:99
Vec3hf(const Vec3hf &copy)
Definition: half_float_vector.h:102
Vec3hf(const HalfFloat *array_xyz)
Definition: half_float_vector.h:94
Vec3hf(const Vec3f &copy)
Definition: half_float_vector.h:104
Vec3hf(const Vec3i &copy)
Definition: half_float_vector.h:105
HalfFloat z
Definition: half_float_vector.h:87
Vec3hf(const Vec2f &copy, float p3)
Definition: half_float_vector.h:97
Vec3f to_float() const
Definition: half_float_vector.h:109
Vec3hf(const Vec2hf &copy, const HalfFloat &p3)
Definition: half_float_vector.h:91
Vec3hf(const Vec3d &copy)
Definition: half_float_vector.h:103
Vec3hf(const float *array_xyz)
Definition: half_float_vector.h:100
HalfFloat y
Definition: half_float_vector.h:86
Vec3hf(const HalfFloat &scalar)
Definition: half_float_vector.h:90
Vec3hf()
Definition: half_float_vector.h:89
Vec3hf(float scalar)
Definition: half_float_vector.h:96
Vec3hf(const Vec4f &copy)
Definition: half_float_vector.h:98
4D half-float vector
Definition: half_float_vector.h:114
Vec4f to_float() const
Definition: half_float_vector.h:142
Vec4hf(const Vec2f &copy, float p3, float p4)
Definition: half_float_vector.h:133
Vec4hf(const HalfFloat &p1, const HalfFloat &p2, const Vec2hf &copy34)
Definition: half_float_vector.h:129
HalfFloat z
Definition: half_float_vector.h:118
Vec4hf(const Vec3hf &copy, const HalfFloat &p4)
Definition: half_float_vector.h:127
HalfFloat w
Definition: half_float_vector.h:119
Vec4hf(const Vec2f &copy, const Vec2f &copy34)
Definition: half_float_vector.h:134
Vec4hf(const HalfFloat &p1, const HalfFloat &p2, const HalfFloat &p3, const HalfFloat &p4)
Definition: half_float_vector.h:128
Vec4hf(const float *array_xyzw)
Definition: half_float_vector.h:138
Vec4hf(const Vec4f &copy)
Definition: half_float_vector.h:122
Vec4hf(const Vec2hf &copy, const Vec2hf &copy34)
Definition: half_float_vector.h:126
Vec4hf()
Definition: half_float_vector.h:121
Vec4hf(const HalfFloat &scalar)
Definition: half_float_vector.h:124
HalfFloat y
Definition: half_float_vector.h:117
HalfFloat x
Definition: half_float_vector.h:116
Vec4hf(const Vec2hf &copy, const HalfFloat &p3, const HalfFloat &p4)
Definition: half_float_vector.h:125
Vec4hf(const HalfFloat *array_xyzw)
Definition: half_float_vector.h:130
Vec4hf(float p1, float p2, const Vec2f &copy34)
Definition: half_float_vector.h:137
Vec4hf(float scalar)
Definition: half_float_vector.h:132
Vec4hf(float p1, float p2, float p3, float p4)
Definition: half_float_vector.h:136
Vec4hf(const Vec3f &copy, float p4)
Definition: half_float_vector.h:135
Vec4< float > Vec4f
Definition: vec4.h:391
Vec3< float > Vec3f
Definition: vec3.h:415
Vec2< float > Vec2f
Definition: vec2.h:425
Definition: clanapp.h:36