mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
Better usage of some floating point constants
This commit is contained in:
@@ -39,7 +39,7 @@ void ComplexGraphView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
* and the line of equation (real*t,imag*t).
|
||||
* (a*cos(t), b*sin(t)) = (real*t,imag*t) --> tan(t) = sign(a)*sign(b) (± π)
|
||||
* --> t = π/4 [π/2] according to sign(a) and sign(b). */
|
||||
float th = real < 0.0f ? 3.0f*(float)M_PI/4.0f : (float)M_PI/4.0f;
|
||||
float th = real < 0.0f ? (float)(3.0*M_PI_4) : (float)M_PI_4;
|
||||
th = imag < 0.0f ? -th : th;
|
||||
// Compute ellipsis parameters a and b
|
||||
float factor = 5.0f;
|
||||
@@ -48,7 +48,7 @@ void ComplexGraphView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
// Avoid flat ellipsis for edge cases (for real = 0, the case imag = 0 is excluded)
|
||||
if (real == 0.0f) {
|
||||
a = 1.0f/factor;
|
||||
th = imag < 0.0f ? -(float)M_PI/2.0f : (float)M_PI/2.0f;
|
||||
th = imag < 0.0f ? (float)-M_PI_2 : (float)M_PI_2;
|
||||
}
|
||||
std::complex<float> parameters(a,b);
|
||||
drawCurve(ctx, rect, 0.0f, 1.0f, 0.01f,
|
||||
|
||||
@@ -377,7 +377,7 @@ void Turtle::drawPaw(PawType type, PawPosition pos) {
|
||||
assert(m_underneathPixelBuffer != nullptr);
|
||||
KDCoordinate pawOffset = 5;
|
||||
constexpr float crawlOffset = 0.6f;
|
||||
constexpr float angles[] = {M_PI_2/2, M_PI_2+M_PI_2/2, -M_PI_2-M_PI_2/2, -M_PI_2/2};
|
||||
constexpr float angles[] = {M_PI_4, 3*M_PI_4, -3*M_PI_4, -M_PI_4};
|
||||
|
||||
// Compute the paw offset from the turtle center
|
||||
float currentAngle = angles[(int) type];
|
||||
|
||||
Reference in New Issue
Block a user