Welcome to mirror list, hosted at ThFree Co, Russian Federation.

vector4d.cpp « util « helper « mantaflow « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d342df607f58ab32a3e2440f6d1de0fd9d045412 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/******************************************************************************
 *
 * MantaFlow fluid solver framework
 * Copyright 2011 Tobias Pfaff, Nils Thuerey
 *
 * This program is free software, distributed under the terms of the
 * Apache License, Version 2.0
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Basic vector class
 *
 ******************************************************************************/

#include "vector4d.h"

using namespace std;

namespace Manta {

template<> const Vector4D<int> Vector4D<int>::Zero(0, 0, 0, 0);
template<> const Vector4D<float> Vector4D<float>::Zero(0.f, 0.f, 0.f, 0.f);
template<> const Vector4D<double> Vector4D<double>::Zero(0., 0., 0., 0.);
template<>
const Vector4D<float> Vector4D<float>::Invalid(numeric_limits<float>::quiet_NaN(),
                                               numeric_limits<float>::quiet_NaN(),
                                               numeric_limits<float>::quiet_NaN(),
                                               numeric_limits<float>::quiet_NaN());
template<>
const Vector4D<double> Vector4D<double>::Invalid(numeric_limits<double>::quiet_NaN(),
                                                 numeric_limits<double>::quiet_NaN(),
                                                 numeric_limits<double>::quiet_NaN(),
                                                 numeric_limits<double>::quiet_NaN());
template<> bool Vector4D<float>::isValid() const
{
  return !c_isnan(x) && !c_isnan(y) && !c_isnan(z) && !c_isnan(t);
}
template<> bool Vector4D<double>::isValid() const
{
  return !c_isnan(x) && !c_isnan(y) && !c_isnan(z) && !c_isnan(t);
}

//! Specialization for readable ints
template<> std::string Vector4D<int>::toString() const
{
  char buf[256];
  snprintf(buf, 256, "[%d,%d,%d,%d]", (*this)[0], (*this)[1], (*this)[2], (*this)[3]);
  return std::string(buf);
}

}  // namespace Manta