Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8144291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:20:16+00:00 2026-06-06T13:20:16+00:00

I am going to develop Android application which needs to read x,y,z coordinates of

  • 0

I am going to develop Android application which needs to read x,y,z coordinates of phone on 3D space.

I would like to write a simple code and test on the device..

I am using ginger bread on both the device and emulator.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:20:17+00:00Added an answer on June 6, 2026 at 1:20 pm

    To get position from acceleration you need to integrate it twice.

    Integrating acceleration gives you velocity and integrating the velocity gives you the position.

    Keep in mind that integrating noise creates drift and integrating drift creates A LOT of drift, the android sensors tend to generate quite a lot of noise.

    On my Galaxy S3 I have been able to get the drift in position down to 0.02 m in 5 seconds using Google’s Linear Accelerometer composite sensor.

    I am not sure if you can use the linear accelerometer sensor on gingerbread. If you can’t you will have to remove the gravity before integrating.

    If you haven’t already, read everything here
    http://developer.android.com/guide/topics/sensors/sensors_motion.html

    A great talk about the motion sensors in android

    http://www.youtube.com/watch?v=C7JQ7Rpwn2k

    Code:

    static final float NS2S = 1.0f / 1000000000.0f;
    float[] last_values = null;
    float[] velocity = null;
    float[] position = null;
    long last_timestamp = 0;
    
    @Override
    public void onSensorChanged(SensorEvent event) {
        if(last_values != null){
            float dt = (event.timestamp - last_timestamp) * NS2S;
    
            for(int index = 0; index < 3;++index){
                velocity[index] += (event.values[index] + last_values[index])/2 * dt;
                position[index] += velocity[index] * dt;
            }
        }
        else{
            last_values = new float[3];
            velocity = new float[3];
            position = new float[3];
            velocity[0] = velocity[1] = velocity[2] = 0f;
            position[0] = position[1] = position[2] = 0f;
        }
        System.arraycopy(event.values, 0, last_values, 0, 3);
        last_timestamp = event.timestamp;
    }
    

    Now you have the position in 3d space, keep in mind it assumes that the phone is stationary when it starts sampling.

    If you don’t remove gravity it will soon be very far away.

    This doesn’t filter the data at all and will generate a lot of drift.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im going to develop one android application which transfer music file, contact exchange, voice
I'm going to develop gui-based application for tor controlling (like vidalia or torK). Are
I'm going to develop a multimedia application which is running mostly on windows. I
when I am going to develop an android application. For better performance of my
We going to develop commercial application that will run on Android platform and now
I'm going to develop apps for iOS, Android and Windows Phone that will be
I am going to develop an application for android using the GEGL library of
I am going to develop an application which will be cross platform and it
I'm going to develop a shopping application which include several cascading forms. The development
I'm going to develop mostly Django sites on a MacBook Pro and would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.