[poincare] Replace complex constructors by named constructors

Change-Id: I6aad82edfb1bd243c4537a48888655608b90eeb5
This commit is contained in:
Émilie Feral
2017-02-14 17:05:18 +01:00
parent 7cbfd37925
commit dc7a629dfa
32 changed files with 96 additions and 82 deletions

View File

@@ -12,14 +12,16 @@ extern "C" {
namespace Poincare {
Complex::Complex(float a, float b, bool polar) :
m_a(a),
m_b(b)
{
if (polar) {
m_a = a * cosf(b);
m_b = a * sinf(b);
}
Complex Complex::Float(float x) {
return Complex(x,0.0f);
}
Complex Complex::Cartesian(float a, float b) {
return Complex(a,b);
}
Complex Complex::Polar(float r, float th) {
return Complex(r*cosf(th),r*sinf(th));
}
static inline float setSign(float f, bool negative) {
@@ -55,7 +57,7 @@ Complex::Complex(const char * integralPart, int integralPartLength, bool integra
}
Expression * Complex::clone() const {
return new Complex(m_a, m_b);
return new Complex(Cartesian(m_a, m_b));
}
float Complex::privateApproximate(Context& context, AngleUnit angleUnit) const {
@@ -136,6 +138,12 @@ int Complex::convertFloatToText(float f, char * buffer, int bufferSize,
return requiredLength;
}
Complex::Complex(float a, float b) :
m_a(a),
m_b(b)
{
}
int Complex::convertComplexToText(char * buffer, int bufferSize, FloatDisplayMode displayMode) const {
assert(displayMode != FloatDisplayMode::Default);
int numberOfChars = 0;