Sha256: 486e17c0ec96ba129c61dbbd637d970a33e11e6bf08c8e09ce6708649c1994a2

Contents?: true

Size: 805 Bytes

Versions: 11

Compression:

Stored size: 805 Bytes

Contents

// Lookup table based sin/cos using degrees.
//
// MUST call initialize_fast_math() before using the fast_ functions.

#ifndef FAST_MATH_H
#define FAST_MATH_H

#include <math.h>
#include <stdio.h>

#define DEGREES_TO_RADIANS(ANGLE) ((ANGLE - 90) * (M_PI / 180.0f))

#define LOOKUPS_PER_DEGREE 10

// Enough for values from 0..360 inclusive
#define NUM_LOOKUP_VALUES (360 * LOOKUPS_PER_DEGREE)

#define LOOKUP_PRECISION (1.0f / LOOKUPS_PER_DEGREE)

extern float sin_lookup[NUM_LOOKUP_VALUES];

void initialize_fast_math();

// sin implementation using lookup table, accepting degrees rather than radians.
float fast_sin_deg(float degrees);

// cos implementation using lookup table, accepting degrees rather than radians.
#define fast_cos_deg(degrees) fast_sin_deg((degrees) + 90.0f)

#endif // FAST_MATH_H

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
danabr75-ashton-0.1.5 ext/ashton/fast_math.h
ashton-0.1.6 ext/ashton/fast_math.h
ashton-0.1.5 ext/ashton/fast_math.h
ashton-0.1.4 ext/ashton/fast_math.h
ashton-0.1.3 ext/ashton/fast_math.h
ashton-0.1.2 ext/ashton/fast_math.h
ashton-0.1.1 ext/ashton/fast_math.h
ashton-0.1.0 ext/ashton/fast_math.h
ashton-0.0.4alpha ext/ashton/fast_math.h
ashton-0.0.3alpha ext/ashton/fast_math.h
ashton-0.0.2alpha ext/ashton/fast_math.h