QUAOAR STUDIO // Mobius API
core_UV.h
1 //-----------------------------------------------------------------------------
2 // Created on: 02 November 2012
3 //-----------------------------------------------------------------------------
4 // Copyright (c) 2017, Sergey Slyadnev
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are met:
9 //
10 // * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 // * Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 // * Neither the name of Sergey Slyadnev nor the
16 // names of all contributors may be used to endorse or promote products
17 // derived from this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 // DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
23 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //-----------------------------------------------------------------------------
30 
31 #ifndef core_UV_HeaderFile
32 #define core_UV_HeaderFile
33 
34 // core includes
35 #include <mobius/core.h>
36 
37 namespace mobius {
38 
42 class core_UV
43 {
44 public:
45 
47  static int num_coordinates()
48  {
49  return 2;
50  }
51 
52 // Construction & destruction:
53 public:
54 
55  mobiusCore_EXPORT
56  core_UV();
57 
58  mobiusCore_EXPORT
59  core_UV(const double u, const double v);
60 
61  mobiusCore_EXPORT
62  core_UV(const core_UV& UV);
63 
64  mobiusCore_EXPORT virtual
65  ~core_UV();
66 
67 public:
68 
71  double U() const
72  {
73  return m_fU;
74  }
75 
78  void SetU(const double u)
79  {
80  m_fU = u;
81  }
82 
85  double V() const
86  {
87  return m_fV;
88  }
89 
92  void SetV(const double v)
93  {
94  m_fV = v;
95  }
96 
100  double Coord(const int idx) const
101  {
102  if ( idx == 0 )
103  return this->U();
104 
105  if ( idx == 1 )
106  return this->V();
107 
108  return 0;
109  }
110 
115  double SetCoord(const int idx,
116  const double val)
117  {
118  double* coord = nullptr;
119 
120  if ( idx == 0 )
121  coord = &m_fU;
122  if ( idx == 1 )
123  coord = &m_fV;
124 
125  if ( coord )
126  *coord = val;
127 
128  return 0;
129  }
130 
132  double GetMaxComponent() const
133  {
134  return m_fU > m_fV ? m_fU : m_fV;
135  }
136 
137 public:
138 
139  mobiusCore_EXPORT double
140  Modulus() const;
141 
142  mobiusCore_EXPORT double
143  SquaredModulus() const;
144 
145  mobiusCore_EXPORT double
146  Dot(const core_UV& UV) const;
147 
148 public:
149 
150  mobiusCore_EXPORT core_UV&
151  operator=(const core_UV& UV);
152 
153  mobiusCore_EXPORT core_UV
154  operator*(const double coeff) const;
155 
156  mobiusCore_EXPORT core_UV
157  operator*=(const double coeff);
158 
159  mobiusCore_EXPORT core_UV
160  operator/(const double coeff) const;
161 
162  mobiusCore_EXPORT core_UV
163  operator/=(const double coeff);
164 
165  mobiusCore_EXPORT core_UV
166  operator+(const core_UV& UV) const;
167 
168  mobiusCore_EXPORT core_UV&
169  operator+=(const core_UV& UV);
170 
171  mobiusCore_EXPORT core_UV
172  Invert() const;
173 
174  mobiusCore_EXPORT core_UV
175  operator-(const core_UV& UV) const;
176 
177  mobiusCore_EXPORT core_UV&
178  operator-=(const core_UV& UV);
179 
180 private:
181 
182  double m_fU;
183  double m_fV;
184 
185 };
186 
193 inline core_UV operator*(const double coeff, const core_UV& coords)
194 {
195  core_UV r = coords*coeff;
196  return r;
197 }
198 
202 typedef core_UV t_uv;
203 
207 typedef core_UV core_XY;
208 
212 typedef core_XY t_xy;
213 
214 }
215 
216 #endif
mobius::core_UV::SetV
void SetV(const double v)
Definition: core_UV.h:92
mobius
Defines an exception class C1 that inherits an exception class C2.
Definition: bspl_Decompose.h:41
mobius::core_UV::SetCoord
double SetCoord(const int idx, const double val)
Definition: core_UV.h:115
mobius::operator*
core_UV operator*(const double coeff, const core_UV &coords)
Definition: core_UV.h:193
mobius::core_UV::SetU
void SetU(const double u)
Definition: core_UV.h:78
mobius::core_UV::V
double V() const
Definition: core_UV.h:85
mobius::t_uv
core_UV t_uv
Definition: core_UV.h:202
mobius::core_UV::Coord
double Coord(const int idx) const
Definition: core_UV.h:100
mobius::core_XY
core_UV core_XY
Definition: core_UV.h:207
mobius::core_UV::U
double U() const
Definition: core_UV.h:71
mobius::t_xy
core_XY t_xy
Definition: core_UV.h:212
mobius::core_UV::num_coordinates
static int num_coordinates()
Definition: core_UV.h:47
mobius::core_UV
Definition: core_UV.h:42
mobius::core_UV::GetMaxComponent
double GetMaxComponent() const
Definition: core_UV.h:132