VISR  0.11.8
Versatile Interactive Scene Renderer
XYZ.h
Go to the documentation of this file.
1 //
2 // XYZ.h
3 //
4 // Created by Dylan Menzies on 09/12/2014.
5 // Copyright (c) ISVR, University of Southampton. All rights reserved.
6 //
7 
8 #ifndef __S3A_renderer_dsp__XYZ__
9 #define __S3A_renderer_dsp__XYZ__
10 
11 #include "defs.h"
12 
13 #include "export_symbols.hpp"
14 
15 #include <iostream>
16 #include <cmath>
17 
18 namespace visr
19 {
20 namespace panning
21 {
22 
23 class VISR_PANNING_LIBRARY_SYMBOL XYZ {
24  public:
28  XYZ();
29 
33  explicit XYZ( Afloat pX, Afloat pY, Afloat pZ, bool pInfinity = false )
34  : x( pX), y( pY ), z( pZ ), isInfinite( pInfinity )
35  {}
36 
40  XYZ & operator=( XYZ const & rhs ) = default;
41 
46  XYZ( XYZ const & rhs ) = default;
47 
48 
49  Afloat x, y, z;
50  bool isInfinite; // eg for source at infinity.
51 
52 
53  int set(Afloat X, Afloat Y, Afloat Z, bool inf = false) {
54  x = X; y = Y; z =Z;
55  isInfinite = inf;
56  return 0;
57  };
58 
59  Afloat getLength() const {
60  return std::sqrt(x*x + y*y + z*z);
61  }
62 
63  Afloat dot( XYZ v) const {
64  return x * v.x + y * v.y + z * v.z;
65  }
66 
67  int minus( XYZ v) {
68  x -= v.x;
69  y -= v.y;
70  z -= v.z;
71  return 0;
72  }
73 
74  int normalise() {
75  Afloat l = getLength();
76  if (l != 0.0f ) {
77  x /= l;
78  y /= l;
79  z /= l;
80  }
81 
82  return 0;
83  }
84 };
85 
86 } // namespace panning
87 } // namespace visr
88 
89 #endif /* defined(__S3A_renderer_dsp__XYZ__) */
bool isInfinite
Definition: XYZ.h:50
Definition: XYZ.h:23
int minus(XYZ v)
Definition: XYZ.h:67
int normalise()
Definition: XYZ.h:74
Afloat x
Definition: XYZ.h:49
Afloat z
Definition: XYZ.h:49
Definition: options.cpp:10
Afloat dot(XYZ v) const
Definition: XYZ.h:63
XYZ(Afloat pX, Afloat pY, Afloat pZ, bool pInfinity=false)
Definition: XYZ.h:33
Afloat getLength() const
Definition: XYZ.h:59
float Afloat
Definition: defs.h:15
Afloat y
Definition: XYZ.h:49