Skip to content

Commit

Permalink
Minor optimizations.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexBx committed Jun 8, 2015
1 parent 83786ea commit f2e6073
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions GeneralStructures.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,19 +227,19 @@ struct DirStruct
double radians() const {
static_assert(Bits > 0 && Bits <= 16, "Bits has to be greater than 0 and lower or equal to 16.");

static const int Max = ((1u << Bits) - 1);
static const int Max = ((1 << Bits) - 1);

double value = Max / 4 - this->value<Bits>();
return value * Math::TwoPi / Max;
int value = Max / 4 - this->value<Bits>();
return -value * -(Math::TwoPi / Max);
}

template <size_t Bits = 16>
void radians(double rad) {
static_assert(Bits > 0 && Bits <= 16, "Bits has to be greater than 0 and lower or equal to 16.");

static const int Max = ((1u << Bits) - 1);
static const int Max = ((1 << Bits) - 1);

int value = static_cast<int>(rad * Max / Math::TwoPi);
int value = static_cast<int>(rad * (Max / Math::TwoPi));
this->value<Bits>(static_cast<value_type>(Max / 4 - value));
}

Expand Down

0 comments on commit f2e6073

Please sign in to comment.