Prius IPM controller

Dependencies:   mbed

Fork of analoghalls5_5 by N K

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers fastmath.cpp Source File

fastmath.cpp

00001 #include "includes.h"
00002 #include "fastmath.h"
00003 #include "lut.h"
00004 
00005 float FastMath::FastSin(float theta) {
00006     if (theta < 0.0f) theta += 360.0f;
00007     if (theta >= 360.0f) theta -= 360.0f;
00008     return 2.0f * sinetab[(int) theta] - 1.0f;
00009 }
00010 
00011 float FastMath::FastCos(float theta) {
00012     return FastSin(90.0f - theta);
00013 }
00014 
00015 float FastMath::FastSin01(float theta) {
00016     return FastSin(theta) * 0.5f + 0.5f;
00017 }
00018 
00019 float FastMath::FastCos01(float theta) {
00020     return FastCos(theta) * 0.5f + 0.5f;
00021 }