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 7793831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:36:42+00:00 2026-06-01T22:36:42+00:00

I am using a 1D vector to represent a 3D data structure, with indices

  • 0

I am using a 1D vector to represent a 3D data structure, with indices 0 to x*y*z, where x, y and z are the number of cells in each direction.

In order to index a specific cell [xi][yi][zi], I use:

index = xi + x*yi + x*y*zi ;

My problem is, I can’t work out how to go the other way!

e.g. I want to get the individual coordinates represented in index 43.

I think I’ve worked out how to get xi:

xi = index % x ;

but I can’t for the life of me get the others… :/

EDIT: Hmmm. Is this right?

xi = index % x;
yi = ((index - xi)/x) % y;
zi = ((index - xi - x*yi) / x) / y ;
  • 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-01T22:36:45+00:00Added an answer on June 1, 2026 at 10:36 pm

    Try this:

    xi =   index % x;
    yi =  (index / x) % y;
    zi = ((index / x) / y) % z;
    

    This can be easily generalized as one might expect.

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

Sidebar

Related Questions

Many data mining algorithms/strategies use vector representation of data records in order to simulate
When using vector, Out of Memory show. To fix it, I use max_size() to
While using the vector why do we sometime use the operator[] like homework[mid] but
I'm using the support vector machine from the e1071 package to classify my data
I tried to use LSI to generate vectors to represent documents. I am using
I'm using a vector of pointers to objects. These objects are derived from a
The following is a C++ program using STL vector container. Just wanted to know
In c++, is using a vector of objects a good idea? If not, what's
So, im trying to create a 3 dimensional 5x3x2 vector, using the vector lib
I have a plug-in vector established using System.AddIn that accepts the body of a

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.