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