Herezh_dev/herezh_pp/contact/Sphere.h

127 lines
5.2 KiB
C++
Executable file

// This file is part of the Herezh++ application.
//
// The finite element software Herezh++ is dedicated to the field
// of mechanics for large transformations of solid structures.
// It is developed by Gérard Rio (APP: IDDN.FR.010.0106078.000.R.P.2006.035.20600)
// INSTITUT DE RECHERCHE DUPUY DE LÔME (IRDL) <https://www.irdl.fr/>.
//
// Herezh++ is distributed under GPL 3 license ou ultérieure.
//
// Copyright (C) 1997-2021 Université Bretagne Sud (France)
// AUTHOR : Gérard Rio
// E-MAIL : gerardrio56@free.fr
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// For more information, please consult: <https://herezh.irdl.fr/>.
/************************************************************************
* DATE: 19/01/2007 *
* $ *
* AUTEUR: G RIO (mailto:gerardrio56@free.fr) *
* $ *
* PROJET: Herezh++ *
* $ *
************************************************************************
* BUT: Def géométrie d'une sphere: un centre et un rayon *
* $ *
* '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' * *
* VERIFICATION: *
* *
* ! date ! auteur ! but ! *
* ------------------------------------------------------------ *
* ! ! ! ! *
* $ *
* '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' *
* MODIFICATIONS: *
* ! date ! auteur ! but ! *
* ------------------------------------------------------------ *
* $ *
************************************************************************/
#ifndef SPHEREE_H
#define SPHEREE_H
#include "Droite.h"
#include "Coordonnee.h"
/// @addtogroup Groupe_sur_les_contacts
/// @{
///
class Sphere
{ // surcharge de l'operator de lecture
friend istream & operator >> (istream &, Sphere &);
// surcharge de l'operator d'ecriture
friend ostream & operator << (ostream &, const Sphere &);
public :
// CONSTRUCTEURS :
// par defaut
Sphere ();
// avec les datas
Sphere ( const Coordonnee& B, const double& r);
// avec la dimension
Sphere (int dim);
// de copie
Sphere ( const Sphere& a);
// DESTRUCTEUR :
~Sphere ();
// surcharge des operator
Sphere& operator = ( const Sphere & P);
// METHODES PUBLIQUES :
// retourne le centre de la Sphere
inline const Coordonnee& CentreSphere() const { return centre;};
// retourne le rayon de la sphere
inline double RayonSphere() const { return rayon;};
// change le centre de la sphere
void Change_centre( const Coordonnee& B);
// change le rayon de la sphere
void Change_rayon( const double & r);
// change toutes les donnees
void change_donnees( const Coordonnee& B, const double& r);
// calcul les deux intercections M1 et M2 d'une droite avec la sphere,
// ramene 0 s'il n'y a pas d'intersection, ramene -1 si l'intercection
// ne peut pas etre calculee
// et 1 s'il y a deux points d'intercection
int Intersection( const Droite & D,Coordonnee& M1, Coordonnee& M2);
// calcul la distance d'un point à la sphere
double Distance_a_sphere(const Coordonnee& M) const;
// ramène true si le point est à l'intérieur de la sphère, false sinon
bool Dedans(const Coordonnee& M)const
{ return ((centre - M).Norme() < rayon);};
// projection d'un point M sur la parois de la sphère
// dans le cas où M = le centre de la sphère, la projection n'est pas
// possible, dans ce cas projection_ok = false en retour, sinon true
Coordonnee Projete(const Coordonnee& M,bool& projection_ok) const;
protected :
// VARIABLES PROTEGEES :
Coordonnee centre; // centre de la sphere
double rayon; // rayon de la sphère
// METHODES PROTEGEES :
};
/// @} // end of group
#endif