View Single Post
  #6   Spotlight this post!  
Unread 07-12-2006, 23:27
TubaMorg TubaMorg is offline
Programmermechanicalelect ricalcoach
AKA: Dan
FRC #1480 (Robatos Locos)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Houston
Posts: 450
TubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond repute
Re: Trig. Functions in EasyC

This is good stuff! Excellent suggestions!

Quote:
Originally Posted by Bongle
I always forget about lookup tables

I'm not sure how much code space the VEX controller has, but 360 floats in a table is 1440 bytes, which is quite a bit. Another idea in that vein would be to have a smaller table (45 entries) and just interpolate between them.
Code:
float GetSin(int degrees)
{
  int subDegrees = degrees & 7; // gets the last 3 bits
  int tableIndex = degrees / 8; // finds out the table entry we want
  return ((8-subDegrees)*table[tableIndex] + subDegrees*table[tableIndex+1])/8;
}
This function is a very simple linear interpolation. But it would allow you to have a much smaller table taking up much less memory. Another improvement would be to only have a table for between -PI/2 and PI/2, then using the same techniques I posted in my first post to get answers for PI/2 and beyond. This would again cut table size in half.
Reply With Quote