Skip to content
Snippets Groups Projects
BallProject.h 1.73 KiB
Newer Older
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ==                                                                        ==
// ============================================================================
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.



/** \file BallProject.h */

#ifndef AMDIS_BALLPROJECT_H
#define AMDIS_BALLPROJECT_H

namespace AMDiS {

  /** \brief
   * Projects world coordinates to the surface of a ball with given center and 
   * radius. Can be used as boundary or volume projection.
   */
  class BallProject : public Projection
  {
  public:
    BallProject(int id, 
		ProjectionType type,
		WorldVector<double> &center,
		double radius) 
      : Projection(id, type),
	center_(center),
	radius_(radius)
    /// Destructor.
    virtual ~BallProject() {}
    /// Implementation of Projection::project();
Thomas Witkowski's avatar
Thomas Witkowski committed
    void project(WorldVector<double> &x) 
    {
      x -= center_;
      double norm = sqrt(x*x);
      TEST_EXIT(norm != 0.0)("can't project vector x\n");
    WorldVector<double> center_;