Linearization of Android Acceleration Input

UPDATE If anyone is looking for a solution to this problem reference the forum post Reset Accelerometer? Is it possible? Tweaking and implementing this solution was much simpler than what I was attempting to accomplish in this post.

Hello fellow Uni-teers, I have a question for all of you math brainers out there. Let me preface this by saying that I probably slept through half of my math classes so if any of my concepts/vocab/understanding of the topic are incorrect, please be gentle :slight_smile:

What I am trying to accomplish:

A simple control system where rotation of the device results in movement around the screen (X and Y only) within a preset confine. The players’ position is based on the delta input from their set default orientation meaning when the user returns the device to the default position, the character returns to the default position as well. (delta input = 1 means player position = 1, 0 = 0 and so forth) This control scheme is very much like the android game My Paper Plane.

What is working:

I have written a formula to convert the default android acceleration input (0 to ± 1 for every 90 degrees of rotation) to something that more suits my needs (0 to ± 2 for every 180 degrees of rotation) This allows me to easily save a default orientation and calculate the delta input from that orientation. This solution is working perfectly for me so far except for…

The problem:

The values that the android device feeds me are not linear. Rather, in a 360 degree cycle, they create a sin wave. This gradual falloff of perceived input (towards the +1/-1 end of the wave) is causing non uniform movement per degree of rotation and even dead spots! This is not conducive to what I want.

The data:

BLUE is a graph of rotation vs. acceleration input that the device currently gives along with the approximated data per 5 degrees of input for 180 degrees.

ORANGE This is what I need the graph to look like. Straight lines, uniform input per unit of rotation, a happy developer :smiley:


What I need:

I need to linearize the data from the android accelerometer (graph 1) to feed into my formula for conversion and movement.

The solution:

This one is for you guys…
Please let me know if anything needs clarification or more information. Also if anyone has a simpler solution to create such movement, I am all ears :slight_smile:

Thanks in advance,

Your friendly neighborhood Space Ninja

If your context allows you to treat this as a signal processing issue, you might look into

Fourier Series

and

a visualization…