16 #ifndef dealii_point_h 17 #define dealii_point_h 20 #include <deal.II/base/config.h> 22 #include <deal.II/base/exceptions.h> 23 #include <deal.II/base/tensor.h> 27 DEAL_II_NAMESPACE_OPEN
105 template <
int dim,
typename Number =
double>
126 explicit Point(
const Number x);
135 Point(
const Number x,
const Number y);
144 Point(
const Number x,
const Number y,
const Number z);
216 template <
typename OtherNumber>
225 template <
typename OtherNumber>
272 template <
class Archive>
274 serialize(Archive &ar,
const unsigned int version);
283 template <
int dim,
typename Number>
289 template <
int dim,
typename Number>
296 template <
int dim,
typename Number>
301 "You can only initialize Point<1> objects using the constructor " 302 "that takes only one argument. Point<dim> objects with dim!=1 " 303 "require initialization with the constructor that takes 'dim' " 321 template <
int dim,
typename Number>
326 "You can only initialize Point<2> objects using the constructor " 327 "that takes two arguments. Point<dim> objects with dim!=2 " 328 "require initialization with the constructor that takes 'dim' " 333 constexpr
unsigned int y_index = (dim < 2) ? 0 : 1;
335 this->
values[y_index] = y;
340 template <
int dim,
typename Number>
345 "You can only initialize Point<3> objects using the constructor " 346 "that takes three arguments. Point<dim> objects with dim!=3 " 347 "require initialization with the constructor that takes 'dim' " 353 constexpr
unsigned int y_index = (dim < 2) ? 0 : 1;
354 constexpr
unsigned int z_index = (dim < 3) ? 0 : 2;
356 this->
values[y_index] = y;
357 this->
values[z_index] = z;
361 template <
int dim,
typename Number>
371 template <
int dim,
typename Number>
376 return this->
values[index];
381 template <
int dim,
typename Number>
386 return this->
values[index];
391 template <
int dim,
typename Number>
402 template <
int dim,
typename Number>
411 template <
int dim,
typename Number>
422 template <
int dim,
typename Number>
427 for (
unsigned int i = 0; i < dim; ++i)
428 result.values[i] = -this->values[i];
434 template <
int dim,
typename Number>
435 template <
typename OtherNumber>
443 for (
unsigned int i = 0; i < dim; ++i)
444 tmp[i] = this->
operator[](i) * factor;
450 template <
int dim,
typename Number>
451 template <
typename OtherNumber>
459 for (
unsigned int i = 0; i < dim; ++i)
460 tmp[i] = this->
operator[](i) / factor;
466 template <
int dim,
typename Number>
470 Number res = Number();
471 for (
unsigned int i = 0; i < dim; ++i)
472 res += this->
operator[](i) * p[i];
477 template <
int dim,
typename Number>
486 template <
int dim,
typename Number>
495 template <
int dim,
typename Number>
500 for (
unsigned int i = 0; i < dim; ++i)
502 const Number diff =
static_cast<Number
>(this->
values[i]) - p(i);
511 template <
int dim,
typename Number>
512 template <
class Archive>
533 template <
int dim,
typename Number,
typename OtherNumber>
550 template <
int dim,
typename Number>
551 inline std::ostream &
552 operator<<(std::ostream &out, const Point<dim, Number> &p)
554 for (
unsigned int i = 0; i < dim - 1; ++i)
567 template <
int dim,
typename Number>
568 inline std::istream &
571 for (
unsigned int i = 0; i < dim; ++i)
585 template <
typename Number>
586 inline std::ostream &
587 operator<<(std::ostream &out, const Point<1, Number> &p)
595 DEAL_II_NAMESPACE_CLOSE
Number operator()(const unsigned int index) const
Point< dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator*(const OtherNumber factor, const Point< dim, Number > &p)
Point< dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator/(const OtherNumber) const
#define AssertIndexRange(index, range)
Tensor< rank_-1, dim, Number > values[(dim!=0)?dim:1]
static Point< dim, Number > unit_vector(const unsigned int i)
numbers::NumberTraits< Number >::real_type distance(const Point< dim, Number > &p) const
static::ExceptionBase & ExcMessage(std::string arg1)
static real_type abs_square(const number &x)
#define Assert(cond, exc)
numbers::NumberTraits< Number >::real_type distance_square(const Point< dim, Number > &p) const
void serialize(Archive &ar, const unsigned int version)
numbers::NumberTraits< Number >::real_type square() const
Point< dim, Number > operator+(const Tensor< 1, dim, Number > &) const
Point< dim, Number > operator-() const
Point< dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator*(const OtherNumber) const
numbers::NumberTraits< Number >::real_type norm_square() const
std::istream & operator>>(std::istream &in, Point< dim, Number > &p)