s/ellipsoid/spheroid + implementation of operator()
This commit is contained in:
parent
dae55f5eab
commit
e76974204d
3 changed files with 39 additions and 23 deletions
|
@ -1,18 +0,0 @@
|
|||
/**
|
||||
* Implementation of an ellipsoid
|
||||
**/
|
||||
|
||||
#include "ellipsoid.hpp"
|
||||
|
||||
Ellipsoid::Ellipsoid(Point& _center, size_t _p, size_t _q) :
|
||||
center(_center), p(_p), q(_q), stiffness(0) {
|
||||
_compute_volume();
|
||||
}
|
||||
|
||||
void Ellipsoid::_compute_volume() {
|
||||
V = (4/3) * PI * p * q * q;
|
||||
}
|
||||
|
||||
void Ellipsoid::set_stiffness(size_t _stiffness) {
|
||||
stiffness = _stiffness;
|
||||
}
|
28
spheroid.cpp
Normal file
28
spheroid.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* Implementation of a spheroid
|
||||
**/
|
||||
|
||||
#include "spheroid.hpp"
|
||||
|
||||
Spheroid::Spheroid(Point& _center, size_t _p, size_t _q) :
|
||||
center(_center), p(_p), q(_q), stiffness(0) {
|
||||
_compute_volume();
|
||||
}
|
||||
|
||||
void Spheroid::_compute_volume() {
|
||||
V = (4/3) * PI * p * q * q;
|
||||
}
|
||||
|
||||
void Spheroid::set_stiffness(size_t _stiffness) {
|
||||
stiffness = _stiffness;
|
||||
}
|
||||
|
||||
|
||||
void Spheroid::update_radius() {
|
||||
q = sqrt((3/4) * V / PI / p);
|
||||
}
|
||||
|
||||
|
||||
void Spheroid::update_center_pos(Point& _center) {
|
||||
center = _center;
|
||||
}
|
|
@ -4,16 +4,23 @@
|
|||
**/
|
||||
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
#include "Implicit.hpp"
|
||||
#include "common_structures.hpp"
|
||||
|
||||
const double PI = 3.141592653589793;
|
||||
|
||||
class Ellipsoid : public ImplicitSurface {
|
||||
class Spheroid : public ImplicitSurface {
|
||||
public:
|
||||
Ellipsoid(Point& _center, size_t _p, size_t _q);
|
||||
void update_center_pos(size_t dt);
|
||||
Spheroid(Point& _center, size_t _p, size_t _q);
|
||||
void update_center_pos(Point& _center);
|
||||
void update_radius();
|
||||
void set_stiffness(size_t _stiffness);
|
||||
double operator() (double _x, double _y, double _z) {
|
||||
return (pow(_x - center.x, 2) / pow(q, 2)
|
||||
+ pow(_y - center.y, 2) / pow(q, 2)
|
||||
+ pow(_z - center.z, 2) / pow(p, 2) -1);
|
||||
}
|
||||
private:
|
||||
/**
|
||||
* p corresponds to the half-height of the ball,
|
||||
|
@ -22,9 +29,8 @@ class Ellipsoid : public ImplicitSurface {
|
|||
* ball
|
||||
**/
|
||||
size_t stiffness;
|
||||
size_t p, q;
|
||||
double p, q;
|
||||
double V;
|
||||
Point& center;
|
||||
void _compute_volume();
|
||||
void _compute_pos(size_t t);
|
||||
};
|
Loading…
Reference in a new issue