Commit 1c0a45bf authored by BRAMAS Berenger's avatar BRAMAS Berenger

Update utils classes.

parent 94ec7f7f
......@@ -38,7 +38,7 @@ public:
* @param inImag the imaginary
* @param inReal the complex[0]
*/
explicit FComplexe(const FReal inImag, const FReal inReal) {
explicit FComplexe(const FReal inReal, const FReal inImag) {
complex[0] = inReal;
complex[1] = inImag;
}
......@@ -93,6 +93,16 @@ public:
this->complex[1] = inImag;
}
/** Return the conjugate */
FComplexe conjugate() const{
return FComplexe(complex[0],-complex[1]);
}
/** Return the conjugate */
FComplexe negate() const{
return FComplexe(-complex[0],-complex[1]);
}
/**
* Operator +=
* in complex[0] with other complex[0], same for complex[1]
......@@ -175,6 +185,12 @@ public:
this->complex[1] += (other.complex[0] * another.complex[1]) + (other.complex[1] * another.complex[0]);
}
/** Mul other and another and add the result to current complexe */
void equalMul(const FComplexe& other, const FComplexe& another){
this->complex[0] = (other.complex[0] * another.complex[0]) - (other.complex[1] * another.complex[1]);
this->complex[1] = (other.complex[0] * another.complex[1]) + (other.complex[1] * another.complex[0]);
}
/** To cast to FReal */
static FReal* ToFReal(FComplexe*const array){
return reinterpret_cast<FReal*>(array);
......
......@@ -80,8 +80,15 @@ struct FMath{
}
/** To get pow */
static double pow(double x, double y){
return ::pow(x,y);
}
static double pow(float x, float y){
return ::powf(x,y);
}
template <class NumType>
static NumType pow(const NumType inValue, int power){
if(power<0) power = -power;
NumType result = 1;
while(power-- > 0) result *= inValue;
return result;
......
......@@ -36,6 +36,11 @@ class FSpherical {
FReal theta; //!< the inclination angle
FReal phi; //!< the azimuth angle
public:
/** Default Constructor, set attributes to 0 */
FSpherical()
: r(0), cosTheta(0), sinTheta(0), theta(0), phi(0) {
}
/** From now, we just need a constructor based on a 3D position */
explicit FSpherical(const FPoint& inVector){
const FReal x2y2 = (inVector.getX() * inVector.getX()) + (inVector.getY() * inVector.getY());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment