View Single Post
  #5   Spotlight this post!  
Unread 07-04-2013, 17:35
MikeE's Avatar
MikeE MikeE is offline
Wrecking nice beaches since 1990
no team (Volunteer)
Team Role: Engineer
 
Join Date: Nov 2008
Rookie Year: 2008
Location: New England -> Alaska
Posts: 381
MikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond reputeMikeE has a reputation beyond repute
Re: Inverse Trig in Java ME

Depending on how you intend to use the trig function, another option is to write a simple routine that gives an approximate but "close enough" answer.

For example, our robot uses a leadscrew to adjust the tilt angle of our climbing mast. There is an encoder attached to the end of the leadscrew so we can measure the distance it has traveled and use the cosine rule to convert this to an angle for the drivers. However to convert from leadscrew distance to angle requires using the acos() function.

Since the range of leadscrew distances are limited by the physical system, our programmers approximated the function using a piecewise linear approximation implemented as a lookup table. While the results are approximate they are close enough for visual display.

This approach is fairly common practice in embedded software, and can be used safely if you do proper error analysis.
Reply With Quote