Mantid
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::Geometry::Sphere Class Reference

Holds a Sphere as vector form. More...

#include <Sphere.h>

Inheritance diagram for Mantid::Geometry::Sphere:
Mantid::Geometry::Quadratic Mantid::Geometry::Surface

Public Member Functions

void acceptVisitor (BaseVisit &A) const override
 Accept visitor for line calculation. More...
 
std::string className () const override
 Effective typename. More...
 
std::unique_ptr< Sphereclone () const
 Makes a clone (implicit virtual copy constructor) More...
 
double distance (const Kernel::V3D &) const override
 Gets the distance from the sphere to the input point. More...
 
void getBoundingBox (double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) override
 Calculates the bounding box for the sphere and returns the bounding box values. More...
 
Kernel::V3D getCentre () const
 Get Centre. More...
 
double getRadius () const
 Get Radius. More...
 
bool onSurface (const Kernel::V3D &) const override
 Checks whether the give input point is on the surface. More...
 
void setBaseEqn () override
 Generates the quadratic equation. More...
 
void setCentre (const Kernel::V3D &)
 Setter for centre of sphere. More...
 
void setRadius (const double &r)
 Set Radius. More...
 
int setSurface (const std::string &) override
 Set the sphere defination by input string in MCNP format. More...
 
int side (const Kernel::V3D &) const override
 Checks the given input point to be inside, outside or on the surface of sphere. More...
 
 Sphere ()
 Default constructor make sphere at the origin radius zero. More...
 
 Sphere (const Kernel::V3D &centre, double radius)
 Sphere::Sphere. More...
 
void write (std::ostream &) const override
 Writes the sphere equatation in MCNP format. More...
 
- Public Member Functions inherited from Mantid::Geometry::Quadratic
void acceptVisitor (BaseVisit &A) const override
 Accept visitor for line calculation. More...
 
std::string className () const override
 Effective typeid. More...
 
std::unique_ptr< Quadraticclone () const
 
const std::vector< double > & copyBaseEqn () const
 access BaseEquation vector More...
 
void displace (const Kernel::V3D &) override
 Apply a general displacement to the surface. More...
 
double distance (const Kernel::V3D &) const override
 distance between point and surface (approx) More...
 
double eqnValue (const Kernel::V3D &) const
 Helper function to calcuate the value of the equation at a fixed point. More...
 
bool onSurface (const Kernel::V3D &) const override
 is point valid on surface More...
 
void print () const override
 Print out the genreal equation for debugging. More...
 
 Quadratic ()
 Constructor. More...
 
void rotate (const Kernel::Matrix< double > &) override
 Rotate the surface by matrix MX. More...
 
virtual void setBaseEqn ()=0
 Abstract set baseEqn. More...
 
int side (const Kernel::V3D &) const override
 Determine if the the Point is true to the surface or on the other side. More...
 
Kernel::V3D surfaceNormal (const Kernel::V3D &) const override
 Normal at surface. More...
 
void write (std::ostream &) const override
 Writes out an MCNPX surface description Note : Swap since base equation is swapped in gq output (mcnp 4c manual pg. More...
 
- Public Member Functions inherited from Mantid::Geometry::Surface
virtual void acceptVisitor (BaseVisit &A) const
 Accept visitor for line calculation. More...
 
virtual std::string className () const
 Effective typeid. More...
 
std::unique_ptr< Surfaceclone () const
 
virtual void displace (const Kernel::V3D &)=0
 translates the surface More...
 
virtual double distance (const Kernel::V3D &) const =0
 returns the minimum distance to the surface More...
 
virtual void getBoundingBox (double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin)=0
 bounding box for the surface More...
 
int getName () const
 Get Name. More...
 
virtual bool onSurface (const Kernel::V3D &R) const =0
 is point valid on surface More...
 
Surfaceoperator= (const Surface &)=delete
 
virtual void print () const
 Simple print out function for surface header. More...
 
virtual void rotate (const Kernel::Matrix< double > &)=0
 rotates the surface More...
 
void setName (int const N)
 Set Name. More...
 
virtual int setSurface (const std::string &R)=0
 Sets the surface based on a string input in MCNPX format. More...
 
virtual int side (const Kernel::V3D &) const
 Surface side : throw AbsObjMethod. More...
 
 Surface ()
 Constructor. More...
 
virtual Kernel::V3D surfaceNormal (const Kernel::V3D &) const =0
 returns the normal to the closest point on the surface More...
 
virtual void write (std::ostream &) const
 The writes the data to the output stream. More...
 
void writeHeader (std::ostream &) const
 Writes out the start of an MCNPX surface description . More...
 
virtual ~Surface ()=default
 

Static Public Attributes

static constexpr int g_NSLICES = 5
 The number of slices to approximate a sphere. More...
 
static constexpr int g_NSTACKS = 5
 The number of stacks to approximate a sphere. More...
 
- Static Public Attributes inherited from Mantid::Geometry::Quadratic
static const int Nprecision = 10
 Precision of the output. More...
 
- Static Public Attributes inherited from Mantid::Geometry::Surface
static const int Nprecision = 10
 Precision of the output. More...
 

Protected Member Functions

Sphereoperator= (const Sphere &)=delete
 
 Sphere (const Sphere &)=default
 
- Protected Member Functions inherited from Mantid::Geometry::Quadratic
Quadraticoperator= (const Quadratic &)=delete
 
 Quadratic (const Quadratic &)=default
 
- Protected Member Functions inherited from Mantid::Geometry::Surface
 Surface (const Surface &)=default
 

Private Member Functions

double centreToPoint (const Kernel::V3D &pt) const
 Compute the distance from the centre of the sphere to the given point. More...
 
void displace (const Kernel::V3D &) override
 Apply a shift of the centre. More...
 
SpheredoClone () const override
 Makes a clone (implicit virtual copy constructor) More...
 
void rotate (const Kernel::Matrix< double > &) override
 Apply a Rotation matrix. More...
 

Private Attributes

Kernel::V3D m_centre
 Point for centre. More...
 
double m_radius
 Radius of sphere. More...
 

Additional Inherited Members

- Protected Attributes inherited from Mantid::Geometry::Quadratic
std::vector< double > BaseEqn
 Base equation (as a 10 point vector) More...
 

Detailed Description

Holds a Sphere as vector form.

Author
S. Ansell
Date
April 2004
Version
1.0

Defines a sphere as a centre point and a radius.

Definition at line 29 of file Sphere.h.

Constructor & Destructor Documentation

◆ Sphere() [1/3]

Mantid::Geometry::Sphere::Sphere ( const Sphere )
protecteddefault

◆ Sphere() [2/3]

Mantid::Geometry::Sphere::Sphere ( )

Default constructor make sphere at the origin radius zero.

Definition at line 38 of file Sphere.cpp.

Referenced by doClone().

◆ Sphere() [3/3]

Mantid::Geometry::Sphere::Sphere ( const Kernel::V3D centre,
double  radius 
)

Sphere::Sphere.

Parameters
centre
radius

Definition at line 45 of file Sphere.cpp.

References setBaseEqn().

Member Function Documentation

◆ acceptVisitor()

void Mantid::Geometry::Sphere::acceptVisitor ( BaseVisit A) const
inlineoverridevirtual

Accept visitor for line calculation.

Reimplemented from Mantid::Geometry::Quadratic.

Definition at line 50 of file Sphere.h.

References Mantid::Geometry::BaseVisit::Accept().

◆ centreToPoint()

double Mantid::Geometry::Sphere::centreToPoint ( const Kernel::V3D pt) const
private

Compute the distance from the centre of the sphere to the given point.

Compute the distance between the given point and the centre of the sphere.

Parameters
pt:: The chosen point

Definition at line 166 of file Sphere.cpp.

References m_centre, and Mantid::Kernel::V3D::norm().

◆ className()

std::string Mantid::Geometry::Sphere::className ( ) const
inlineoverridevirtual

Effective typename.

Reimplemented from Mantid::Geometry::Quadratic.

Definition at line 48 of file Sphere.h.

◆ clone()

std::unique_ptr< Sphere > Mantid::Geometry::Sphere::clone ( ) const

Makes a clone (implicit virtual copy constructor)

Returns
new (*this)

Definition at line 59 of file Sphere.cpp.

References doClone().

◆ displace()

void Mantid::Geometry::Sphere::displace ( const Kernel::V3D Pt)
overrideprivatevirtual

Apply a shift of the centre.

Parameters
Pt:: distance to add to the centre

Reimplemented from Mantid::Geometry::Quadratic.

Definition at line 148 of file Sphere.cpp.

References Mantid::Geometry::Quadratic::displace(), and m_centre.

Referenced by side().

◆ distance()

double Mantid::Geometry::Sphere::distance ( const Kernel::V3D Pt) const
overridevirtual

Gets the distance from the sphere to the input point.

Determine the shortest distance from the Surface to the Point.

Parameters
Pt:: Point to calculate distance from
Returns
distance (Positive only)

Reimplemented from Mantid::Geometry::Quadratic.

Definition at line 139 of file Sphere.cpp.

References m_centre, m_radius, and Mantid::Kernel::V3D::norm().

Referenced by onSurface().

◆ doClone()

Sphere * Mantid::Geometry::Sphere::doClone ( ) const
overrideprivatevirtual

Makes a clone (implicit virtual copy constructor)

Returns
new (*this)

Implements Mantid::Geometry::Quadratic.

Definition at line 53 of file Sphere.cpp.

References Sphere().

Referenced by clone().

◆ getBoundingBox()

void Mantid::Geometry::Sphere::getBoundingBox ( double &  xmax,
double &  ymax,
double &  zmax,
double &  xmin,
double &  ymin,
double &  zmin 
)
overridevirtual

Calculates the bounding box for the sphere and returns the bounding box values.

Parameters
xmax:: input and output for the bounding box X axis max value
ymax:: input and output for the bounding box Y axis max value
zmax:: input and output for the bounding box Z axis max value
xmin:: input and output for the bounding box X axis min value
ymin:: input and output for the bounding box Y axis min value
zmin:: input and output for the bounding box Z axis min value

Implements Mantid::Geometry::Surface.

Definition at line 224 of file Sphere.cpp.

References m_centre, and m_radius.

◆ getCentre()

Kernel::V3D Mantid::Geometry::Sphere::getCentre ( ) const
inline

Get Centre.

Definition at line 63 of file Sphere.h.

◆ getRadius()

double Mantid::Geometry::Sphere::getRadius ( ) const
inline

Get Radius.

Definition at line 65 of file Sphere.h.

◆ onSurface()

bool Mantid::Geometry::Sphere::onSurface ( const Kernel::V3D Pt) const
overridevirtual

Checks whether the give input point is on the surface.

Calculate if the point Pt on the surface of the sphere (within tolerance CTolerance)

Parameters
Pt:: Point to check

Reimplemented from Mantid::Geometry::Quadratic.

Definition at line 131 of file Sphere.cpp.

References distance(), and Mantid::Kernel::Tolerance.

◆ operator=()

Sphere & Mantid::Geometry::Sphere::operator= ( const Sphere )
protecteddelete

◆ rotate()

void Mantid::Geometry::Sphere::rotate ( const Kernel::Matrix< double > &  MA)
overrideprivatevirtual

Apply a Rotation matrix.

Parameters
MA:: matrix to rotate by

Reimplemented from Mantid::Geometry::Quadratic.

Definition at line 157 of file Sphere.cpp.

References m_centre, Mantid::Geometry::Quadratic::rotate(), and Mantid::Kernel::V3D::rotate().

◆ setBaseEqn()

void Mantid::Geometry::Sphere::setBaseEqn ( )
overridevirtual

Generates the quadratic equation.

Sets an equation of type (general sphere)

\[ x^2+y^2+z^2+Gx+Hy+Jz+K=0 \]

Implements Mantid::Geometry::Quadratic.

Definition at line 184 of file Sphere.cpp.

References Mantid::Geometry::Quadratic::BaseEqn, m_centre, m_radius, and Mantid::Kernel::V3D::scalar_prod().

Referenced by setCentre(), setSurface(), and Sphere().

◆ setCentre()

void Mantid::Geometry::Sphere::setCentre ( const Kernel::V3D A)

Setter for centre of sphere.

Set the centre point.

Parameters
A:: New Centre Point

Definition at line 175 of file Sphere.cpp.

References m_centre, and setBaseEqn().

◆ setRadius()

void Mantid::Geometry::Sphere::setRadius ( const double &  r)
inline

Set Radius.

Definition at line 67 of file Sphere.h.

◆ setSurface()

int Mantid::Geometry::Sphere::setSurface ( const std::string &  Pstr)
overridevirtual

Set the sphere defination by input string in MCNP format.

Processes a standard MCNPX cone string Recall that cones can only be specified on an axis Valid input is:

  • so radius
  • s cen_x cen_y cen_z radius
  • sx - cen_x radius
    Returns
    : 0 on success, neg of failure

Implements Mantid::Geometry::Surface.

Definition at line 70 of file Sphere.cpp.

References index, m_centre, m_radius, Mantid::Kernel::Strings::section(), and setBaseEqn().

◆ side()

int Mantid::Geometry::Sphere::side ( const Kernel::V3D Pt) const
overridevirtual

Checks the given input point to be inside, outside or on the surface of sphere.

Calculate where the point Pt is relative to the sphere.

Parameters
Pt:: Point to test
Return values
-1:: Pt within sphere
0:: point on the surface (within CTolerance)
1:: Pt outside the sphere

Reimplemented from Mantid::Geometry::Quadratic.

Definition at line 112 of file Sphere.cpp.

References displace(), fabs, m_centre, m_radius, Mantid::Kernel::Tolerance, Mantid::Kernel::V3D::X(), Mantid::Kernel::V3D::Y(), and Mantid::Kernel::V3D::Z().

◆ write()

void Mantid::Geometry::Sphere::write ( std::ostream &  OX) const
overridevirtual

Writes the sphere equatation in MCNP format.

Object of write is to output a MCNPX plane info.

Parameters
OX:: Output stream (required for multiple std::endl)
Todo:
(Needs precision)

Reimplemented from Mantid::Geometry::Quadratic.

Definition at line 202 of file Sphere.cpp.

References Mantid::Kernel::V3D::distance(), m_centre, m_radius, Mantid::Geometry::Surface::Nprecision, Mantid::Kernel::Tolerance, Mantid::Geometry::Surface::writeHeader(), and Mantid::Kernel::Strings::writeMCNPX().

Member Data Documentation

◆ g_NSLICES

constexpr int Mantid::Geometry::Sphere::g_NSLICES = 5
staticconstexpr

The number of slices to approximate a sphere.

Definition at line 78 of file Sphere.h.

◆ g_NSTACKS

constexpr int Mantid::Geometry::Sphere::g_NSTACKS = 5
staticconstexpr

The number of stacks to approximate a sphere.

Definition at line 80 of file Sphere.h.

◆ m_centre

Kernel::V3D Mantid::Geometry::Sphere::m_centre
private

Point for centre.

Definition at line 31 of file Sphere.h.

Referenced by centreToPoint(), displace(), distance(), getBoundingBox(), rotate(), setBaseEqn(), setCentre(), setSurface(), side(), and write().

◆ m_radius

double Mantid::Geometry::Sphere::m_radius
private

Radius of sphere.

Definition at line 32 of file Sphere.h.

Referenced by distance(), getBoundingBox(), setBaseEqn(), setSurface(), side(), and write().


The documentation for this class was generated from the following files: