ParticleAttribute[ GAMB | Source | Keywords | Summary | Ancestors | All Members | Descendants ]
| public: | |
| ParticleAttribute(); | |
| ParticleAttribute(const Func& func); | |
| ParticleAttribute(const ParticleAttribute& par); | |
| // Info and updates | |
| Func | measure() const ; |
| void | updateMeasureFunc(const Func& new_measure); |
| // Operators | |
| float | operator()(const AttributeT& att1, const AttributeT& att2); |
| bool | operator==(const ParticleAttribute& att); |
| protected: |
Back to the top of ParticleAttribute
Back to the top of ParticleAttribute
Back to the top of ParticleAttribute
Back to the top of ParticleAttribute
File: "Euclidean .h"
#include <Vector3.h>
class VectorDist {
public:
float operator()(const Vector3& vec1, const Vector3& vec2) {
return vec1.dist(vec2);
};
class VectorProd {
public:
float operator()(const Vector3& vec1, const Vector3& vec2) {
return vec1*vec2;
};
class VecSumNorm {
public:
float operator()(const Vector3& vec1, const Vector3& vec2) {
return vec1.norm()+vec2.norm();
}
class VecSubNorm {
public:
float operator()(const Vector3& vec1, const Vecotr3& vec2) {
return vec1.norm()-vec2.norm();
}
#endif
Now anytime you want to measure things on vector all you need to do is:
#include "ParticleAttribute.h"
#include "Euclidean.h"
#include "Vector3.h"
#include <vector>
void do_staff_function() {
ParticleAttribute<Vecotr3, VecSubNorm> diff_in_norm;
ParticleAttribute<Vector3, VecProduct> prod_vec;
vector<Vector3> my_vec;
.... here come a part where you enter info to your vector.
.... Now you want to know the difference in norm and the dot product between element i and element j
diff_in_norm(elem_i, elem_j); prod_vec(elem_i, elem_j);
Now lets assume we have a particle class that hold mass information and location, and we can get it from the class. We want to compute their gravitational attraction according to Newton:
#include "macros.h"
#include "ParticleAttribute.h"
class GravNewt {
public:
operator()(const MassParticle& pr1, const MassParticle& pr2) {
const float G=6.67e-11;
return (G*pr1.mass()*pr2.mass()
/ sqr(pr1.location().dist(pr2.location())));
};
Assuming we measure the planets place in distance from sun, and of
a star in the milky way in the distance from the center of the galaxy.
void GravOfSun(const MassParticle& planet_in_solar_system,
const MassParticle& star_in_milky_way)
{
MassParticle Sun(mass_of_sun, Vector3(0,0,0));
ParticleAttribute<MassParticle, GravNewt> gravity;
cout << "The gravity influence of the sun on a planet in the solar "
<<" system is "
<< gravity(Sun,planet_in_solar_system) << endl;
cout << "The gravity influence of the sun on a star in the"
<< " milky way is "
<< gravity(MassParticle(mass_of_sun, dist_of_sun_from_mid_galaxy),
star_in_milky_way)
<< endl;
Copyright: SAMBA group, Tel-Aviv Univ. ISRAEL, 1998.
Back to the top of ParticleAttribute
ParticleAttribute();
GROUP: Constructors
// empty constructor for future usage with the STL vector constructor
ParticleAttribute();
Back to the top of ParticleAttribute
ParticleAttribute(const Func& func);
The regular constructor make sure that AttributeT and Func has
copy constructor
ParticleAttribute(const Func& func);
Back to the top of ParticleAttribute
ParticleAttribute(const ParticleAttribute& par);
Copy constructor again for vector utils
ParticleAttribute(const ParticleAttribute& par);
Back to the top of ParticleAttribute
Func measure() const ;
Returns the measuring function
Func measure() const
;
Function is currently defined inline.
Back to the top of ParticleAttribute
void updateMeasureFunc(const Func& new_measure);
Updating the measuring function
void updateMeasureFunc(const Func& new_measure);
Back to the top of ParticleAttribute
float operator()(const AttributeT& att1, const AttributeT& att2);
The applying operator.
float operator()(const AttributeT& att1, const AttributeT& att2);
Back to the top of ParticleAttribute
bool operator==(const ParticleAttribute& att);
Equivalence measure gives a boolean answer whether the attributes
are the same in a "lexicographic manner" i.e if the attributes aren't
identical it returns false if they are it checks if the
measure functions associated with them is
bool operator==(const ParticleAttribute& att);
Back to the top of ParticleAttribute
| public: | ||
|---|---|---|
| // Info and updates | ||
| Func | measure() const ; | |
| void | updateMeasureFunc(const Func& new_measure); | |
| // Operators | ||
| float | operator()(const AttributeT& att1, const AttributeT& att2); | |
| bool | operator==(const ParticleAttribute& att); | |
| protected: | ||
Back to the top of ParticleAttribute
Back to the top of ParticleAttribute
Back to the top of ParticleAttribute
Report problems to jkotula@unimax.com