Browse Source

math: add τ (tau) to the list of maths constants.

undefined
Sam Hocevar 9 years ago
parent
commit
c7567975e3
2 changed files with 20 additions and 13 deletions
  1. +11
    -7
      src/lol/math/constants.h
  2. +9
    -6
      src/math/real.cpp

+ 11
- 7
src/lol/math/constants.h View File

@@ -1,18 +1,20 @@
//
// Lol Engine
// Lol Engine
//
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#pragma once

//
// Various maths constants
// -----------------------
// ———————————————————————
//

#include <lol/base/types.h>
@@ -27,6 +29,8 @@ namespace lol

/* These values are truncated, not rounded, because I don’t care. */

LOL_MATH_CONSTANT(TAU, 6.28318530717958647692528676655900576839433879875L)

LOL_MATH_CONSTANT(PI, 3.14159265358979323846264338327950288419716939937L)
LOL_MATH_CONSTANT(PI_2, 1.57079632679489661923132169163975144209858469968L)
LOL_MATH_CONSTANT(PI_3, 1.04719755119659774615421446109316762806572313312L)


+ 9
- 6
src/math/real.cpp View File

@@ -1,11 +1,13 @@
//
// Lol Engine
// Lol Engine
//
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#include <lol/engine-internal.h>
@@ -55,6 +57,7 @@ LOL_CONSTANT_GETTER(R_PI, fast_pi());
LOL_CONSTANT_GETTER(R_PI_2, R_PI() / 2);
LOL_CONSTANT_GETTER(R_PI_3, R_PI() / R_3());
LOL_CONSTANT_GETTER(R_PI_4, R_PI() / 4);
LOL_CONSTANT_GETTER(R_TAU, R_PI() + R_PI());
LOL_CONSTANT_GETTER(R_1_PI, inverse(R_PI()));
LOL_CONSTANT_GETTER(R_2_PI, R_1_PI() * 2);
LOL_CONSTANT_GETTER(R_2_SQRTPI, inverse(sqrt(R_PI())) * 2);


Loading…
Cancel
Save