Euphoria
vec4.cc
Go to the documentation of this file.
1 #include "base/vec4.h"
2 
3 
4 namespace eu
5 {
6  vec4f::vec4f(float a)
7  : x(a)
8  , y(a)
9  , z(a)
10  , w(a)
11  {
12  }
13 
14 
15  vec4f::vec4f(float ax, float ay, float az, float aw)
16  : x(ax)
17  , y(ay)
18  , z(az)
19  , w(aw)
20  {
21  }
22 
23 
24  vec4f::vec4f(const vec3f& a, float aw)
25  : x(a.x)
26  , y(a.y)
27  , z(a.z)
28  , w(aw)
29  {
30  }
31 
32 
34  : x(a.x)
35  , y(a.y)
36  , z(a.z)
37  , w(1)
38  {
39  }
40 
41 
42  vec4f::vec4f(const float* a)
43  : x(a[0])
44  , y(a[1])
45  , z(a[2])
46  , w(a[3])
47  {
48  }
49 
50 
51  vec3f
52  vec4f::to_vec3(float ww) const
53  {
54  ASSERTX(is_equal(w, ww), w, ww);
55  return {x, y, z};
56  }
57 
58 
59  vec3f
61  {
62  return {x, y, z};
63  }
64 
65 
66  float*
68  {
69  return &x;
70  }
71 
72 
73  const float*
75  {
76  return &x;
77  }
78 
79 
80  std::string to_string(const vec4f& v)
81  {
82  return fmt::format("({}, {}, {}, {})", v.x, v.y, v.z, v.w);
83  }
84 }
#define ASSERTX(x,...)
Definition: assert.h:48
Definition: assert.h:90
std::string to_string(const Aabb &a)
Definition: aabb.cc:110
bool is_equal(int lhs, int rhs)
Definition: numeric.cc:13
Definition: vec3.h:48
Definition: vec4.h:14
float * get_data_ptr()
Definition: vec4.cc:67
float w
Definition: vec4.h:18
float x
Definition: vec4.h:15
float y
Definition: vec4.h:16
float z
Definition: vec4.h:17
vec3f to_vec3() const
Definition: vec4.cc:60
vec4f(float a)
Definition: vec4.cc:6