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:
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:
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:
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 
Vec3< float > Vec3f
Definition: vec3.h:426
Vec4< float > Vec4f
Definition: vec4.h:402
Vec4hf(const Vec3f &copy, float p4)
Definition: half_float_vector.h:137
Vec4hf(const HalfFloat &p1, const HalfFloat &p2, const HalfFloat &p3, const HalfFloat &p4)
Definition: half_float_vector.h:130
Vec4hf(float p1, float p2, const Vec2f &copy34)
Definition: half_float_vector.h:139
Vec4f to_float() const
Definition: half_float_vector.h:144
Vec4hf(const Vec3hf &copy, const HalfFloat &p4)
Definition: half_float_vector.h:129
Vec2hf(float scalar)
Definition: half_float_vector.h:64
HalfFloat x
Definition: half_float_vector.h:87
Vec3hf(const Vec2f &copy, float p3)
Definition: half_float_vector.h:99
Vec2hf(const Pointx< double > &point)
Definition: half_float_vector.h:71
Vec4hf(const float *array_xyzw)
Definition: half_float_vector.h:140
Vec4hf(const Vec2hf &copy, const Vec2hf &copy34)
Definition: half_float_vector.h:128
Vec2hf(const Vec2i &copy)
Definition: half_float_vector.h:76
Vec4hf(const HalfFloat *array_xyzw)
Definition: half_float_vector.h:132
Vec3hf(const float *array_xyz)
Definition: half_float_vector.h:102
Vec2hf(const Vec4f &copy)
Definition: half_float_vector.h:66
Vec3hf()
Definition: half_float_vector.h:91
Vec3f to_float() const
Definition: half_float_vector.h:111
Definition: half_float.h:40
Vec4hf(const Vec2f &copy, float p3, float p4)
Definition: half_float_vector.h:135
Vec2hf(const Pointx< float > &point)
Definition: half_float_vector.h:70
Vec3hf(float scalar)
Definition: half_float_vector.h:98
Vec3hf(const Vec2hf &copy, const HalfFloat &p3)
Definition: half_float_vector.h:93
Vec3hf(const HalfFloat *array_xyz)
Definition: half_float_vector.h:96
Vec2hf(const Pointx< int > &point)
Definition: half_float_vector.h:69
Vec2hf(const Vec2d &copy)
Definition: half_float_vector.h:74
Vec2hf(const HalfFloat &scalar)
Definition: half_float_vector.h:58
Vec2hf(const HalfFloat &p1, const HalfFloat &p2)
Definition: half_float_vector.h:61
Vec3hf(const Vec3d &copy)
Definition: half_float_vector.h:105
Vec3hf(const HalfFloat &p1, const HalfFloat &p2, const HalfFloat &p3)
Definition: half_float_vector.h:95
Vec3hf(const Vec3i &copy)
Definition: half_float_vector.h:107
Vec2hf()
Definition: half_float_vector.h:56
Vec4hf(const HalfFloat &scalar)
Definition: half_float_vector.h:126
Vec3hf(const Vec4f &copy)
Definition: half_float_vector.h:100
2D vector
Definition: line.h:48
HalfFloat z
Definition: half_float_vector.h:89
Vec2hf(float *array_xy)
Definition: half_float_vector.h:68
HalfFloat x
Definition: half_float_vector.h:53
Vec2f to_float() const
Definition: half_float_vector.h:80
HalfFloat x
Definition: half_float_vector.h:118
Vec4hf(const Vec4f &copy)
Definition: half_float_vector.h:124
HalfFloat y
Definition: half_float_vector.h:54
Vec3hf(const Vec3hf &copy)
Definition: half_float_vector.h:104
Vec4hf(const HalfFloat &p1, const HalfFloat &p2, const Vec2hf &copy34)
Definition: half_float_vector.h:131
Vec3hf(const HalfFloat &scalar)
Definition: half_float_vector.h:92
HalfFloat w
Definition: half_float_vector.h:121
Definition: clanapp.h:36
Vec2< float > Vec2f
Definition: vec2.h:435
HalfFloat y
Definition: half_float_vector.h:119
HalfFloat z
Definition: half_float_vector.h:120
Vec3hf(const Vec3f &copy)
Definition: half_float_vector.h:106
Vec4hf(const Vec2hf &copy, const HalfFloat &p3, const HalfFloat &p4)
Definition: half_float_vector.h:127
Vec4hf(const Vec2f &copy, const Vec2f &copy34)
Definition: half_float_vector.h:136
HalfFloat y
Definition: half_float_vector.h:88
Vec2hf(const Vec2f &copy)
Definition: half_float_vector.h:75
Vec2hf(const Vec2hf &copy)
Definition: half_float_vector.h:73
3D vector
Definition: line_ray.h:48
Vec2hf(float p1, float p2)
Definition: half_float_vector.h:67
Vec2hf(const HalfFloat *array_xy)
Definition: half_float_vector.h:62
Vec4hf(float scalar)
Definition: half_float_vector.h:134
Vec2hf(const Vec3f &copy)
Definition: half_float_vector.h:65
Vec3hf(float p1, float p2, float p3)
Definition: half_float_vector.h:101
Vec4hf()
Definition: half_float_vector.h:123
Vec4hf(float p1, float p2, float p3, float p4)
Definition: half_float_vector.h:138
3D half-float vector
Definition: half_float_vector.h:85
2D half-float vector
Definition: half_float_vector.h:51
4D half-float vector
Definition: half_float_vector.h:116