half_float_vector.h Source File - ClanLib SDK
Description: half_float_vector.h Source File

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:
51 HalfFloat x;
52 HalfFloat y;
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:
85 HalfFloat x;
86 HalfFloat y;
87 HalfFloat z;
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:
116 HalfFloat x;
117 HalfFloat y;
118 HalfFloat z;
119 HalfFloat w;
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}
clan::HalfFloat
Definition half_float.h:37
clan::Pointx
2D (x,y) point structure.
Definition vec4.h:64
clan::Vec2< double >
clan::Vec2hf
2D half-float vector
Definition half_float_vector.h:49
clan::Vec2hf::Vec2hf
Vec2hf(const Pointx< int > &point)
Definition half_float_vector.h:67
clan::Vec2hf::Vec2hf
Vec2hf(const Pointx< double > &point)
Definition half_float_vector.h:69
clan::Vec2hf::Vec2hf
Vec2hf(const HalfFloat &p1, const HalfFloat &p2)
Definition half_float_vector.h:59
clan::Vec2hf::Vec2hf
Vec2hf(float p1, float p2)
Definition half_float_vector.h:65
clan::Vec2hf::Vec2hf
Vec2hf()
Definition half_float_vector.h:54
clan::Vec2hf::Vec2hf
Vec2hf(float scalar)
Definition half_float_vector.h:62
clan::Vec2hf::to_float
Vec2f to_float() const
Definition half_float_vector.h:78
clan::Vec2hf::Vec2hf
Vec2hf(const Pointx< float > &point)
Definition half_float_vector.h:68
clan::Vec2hf::Vec2hf
Vec2hf(const Vec2f &copy)
Definition half_float_vector.h:73
clan::Vec2hf::x
HalfFloat x
Definition half_float_vector.h:51
clan::Vec2hf::Vec2hf
Vec2hf(float *array_xy)
Definition half_float_vector.h:66
clan::Vec2hf::Vec2hf
Vec2hf(const Vec2hf &copy)
Definition half_float_vector.h:71
clan::Vec2hf::Vec2hf
Vec2hf(const Vec2d &copy)
Definition half_float_vector.h:72
clan::Vec2hf::Vec2hf
Vec2hf(const Vec4f &copy)
Definition half_float_vector.h:64
clan::Vec2hf::Vec2hf
Vec2hf(const HalfFloat *array_xy)
Definition half_float_vector.h:60
clan::Vec2hf::Vec2hf
Vec2hf(const Vec2i &copy)
Definition half_float_vector.h:74
clan::Vec2hf::y
HalfFloat y
Definition half_float_vector.h:52
clan::Vec2hf::Vec2hf
Vec2hf(const Vec3f &copy)
Definition half_float_vector.h:63
clan::Vec2hf::Vec2hf
Vec2hf(const HalfFloat &scalar)
Definition half_float_vector.h:56
clan::Vec3< float >
clan::Vec3hf
3D half-float vector
Definition half_float_vector.h:83
clan::Vec3hf::x
HalfFloat x
Definition half_float_vector.h:85
clan::Vec3hf::Vec3hf
Vec3hf(const HalfFloat &p1, const HalfFloat &p2, const HalfFloat &p3)
Definition half_float_vector.h:93
clan::Vec3hf::Vec3hf
Vec3hf(float p1, float p2, float p3)
Definition half_float_vector.h:99
clan::Vec3hf::Vec3hf
Vec3hf(const Vec3hf &copy)
Definition half_float_vector.h:102
clan::Vec3hf::Vec3hf
Vec3hf(const HalfFloat *array_xyz)
Definition half_float_vector.h:94
clan::Vec3hf::Vec3hf
Vec3hf(const Vec3f &copy)
Definition half_float_vector.h:104
clan::Vec3hf::Vec3hf
Vec3hf(const Vec3i &copy)
Definition half_float_vector.h:105
clan::Vec3hf::z
HalfFloat z
Definition half_float_vector.h:87
clan::Vec3hf::Vec3hf
Vec3hf(const Vec2f &copy, float p3)
Definition half_float_vector.h:97
clan::Vec3hf::to_float
Vec3f to_float() const
Definition half_float_vector.h:109
clan::Vec3hf::Vec3hf
Vec3hf(const Vec2hf &copy, const HalfFloat &p3)
Definition half_float_vector.h:91
clan::Vec3hf::Vec3hf
Vec3hf(const Vec3d &copy)
Definition half_float_vector.h:103
clan::Vec3hf::Vec3hf
Vec3hf(const float *array_xyz)
Definition half_float_vector.h:100
clan::Vec3hf::y
HalfFloat y
Definition half_float_vector.h:86
clan::Vec3hf::Vec3hf
Vec3hf(const HalfFloat &scalar)
Definition half_float_vector.h:90
clan::Vec3hf::Vec3hf
Vec3hf()
Definition half_float_vector.h:89
clan::Vec3hf::Vec3hf
Vec3hf(float scalar)
Definition half_float_vector.h:96
clan::Vec3hf::Vec3hf
Vec3hf(const Vec4f &copy)
Definition half_float_vector.h:98
clan::Vec4< float >
clan::Vec4hf
4D half-float vector
Definition half_float_vector.h:114
clan::Vec4hf::to_float
Vec4f to_float() const
Definition half_float_vector.h:142
clan::Vec4hf::Vec4hf
Vec4hf(const Vec2f &copy, float p3, float p4)
Definition half_float_vector.h:133
clan::Vec4hf::Vec4hf
Vec4hf(const HalfFloat &p1, const HalfFloat &p2, const Vec2hf &copy34)
Definition half_float_vector.h:129
clan::Vec4hf::z
HalfFloat z
Definition half_float_vector.h:118
clan::Vec4hf::Vec4hf
Vec4hf(const Vec3hf &copy, const HalfFloat &p4)
Definition half_float_vector.h:127
clan::Vec4hf::w
HalfFloat w
Definition half_float_vector.h:119
clan::Vec4hf::Vec4hf
Vec4hf(const Vec2f &copy, const Vec2f &copy34)
Definition half_float_vector.h:134
clan::Vec4hf::Vec4hf
Vec4hf(const HalfFloat &p1, const HalfFloat &p2, const HalfFloat &p3, const HalfFloat &p4)
Definition half_float_vector.h:128
clan::Vec4hf::Vec4hf
Vec4hf(const float *array_xyzw)
Definition half_float_vector.h:138
clan::Vec4hf::Vec4hf
Vec4hf(const Vec4f &copy)
Definition half_float_vector.h:122
clan::Vec4hf::Vec4hf
Vec4hf(const Vec2hf &copy, const Vec2hf &copy34)
Definition half_float_vector.h:126
clan::Vec4hf::Vec4hf
Vec4hf()
Definition half_float_vector.h:121
clan::Vec4hf::Vec4hf
Vec4hf(const HalfFloat &scalar)
Definition half_float_vector.h:124
clan::Vec4hf::y
HalfFloat y
Definition half_float_vector.h:117
clan::Vec4hf::x
HalfFloat x
Definition half_float_vector.h:116
clan::Vec4hf::Vec4hf
Vec4hf(const Vec2hf &copy, const HalfFloat &p3, const HalfFloat &p4)
Definition half_float_vector.h:125
clan::Vec4hf::Vec4hf
Vec4hf(const HalfFloat *array_xyzw)
Definition half_float_vector.h:130
clan::Vec4hf::Vec4hf
Vec4hf(float p1, float p2, const Vec2f &copy34)
Definition half_float_vector.h:137
clan::Vec4hf::Vec4hf
Vec4hf(float scalar)
Definition half_float_vector.h:132
clan::Vec4hf::Vec4hf
Vec4hf(float p1, float p2, float p3, float p4)
Definition half_float_vector.h:136
clan::Vec4hf::Vec4hf
Vec4hf(const Vec3f &copy, float p4)
Definition half_float_vector.h:135
clan::Vec4f
Vec4< float > Vec4f
Definition vec4.h:391
clan::Vec3f
Vec3< float > Vec3f
Definition vec3.h:415
clan::Vec2f
Vec2< float > Vec2f
Definition vec2.h:425
clan::FillMode::point
@ point
clan
Definition clanapp.h:36
clan::Key::y
@ y
clan::Key::x
@ x
clan::Key::z
@ z