LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-02-2004, 10:39 PM   #1
chewysplace
Member
 
Registered: Sep 2003
Distribution: Slackware 10 w/ Kernel 2.6.8
Posts: 176

Rep: Reputation: 30
Question 4th Demensional Arrays in C++


First of all, anyone got any alternatives . Second if i have to use it does anyone have a good algorithm for it or know a site where i can get one? Using it to keep track of information in a 3D world so my AI can recall key points in the map that is loaded instead of just running wild looking for things. I've thought about the "Smart Terrain" theory but its just not to my taste. Any help would be appreciated.
 
Old 03-03-2004, 01:06 AM   #2
hypexr
Member
 
Registered: Oct 2003
Location: USA Fresno Callifornia
Distribution: Gentoo (workstation), ArchLinux (file/mail server), Freebsd (web server), Ubuntu (laptop)
Posts: 115

Rep: Reputation: 16
shouldn't a 3 demensional array work? Why the 4th?
 
Old 03-03-2004, 01:10 AM   #3
biosx
Member
 
Registered: Jul 2002
Location: Chicagoland
Distribution: Gentoo, Ubuntu
Posts: 63

Rep: Reputation: 15
Instead of using a 4-D array why not use a 1-D array of a data structure that holds data on 3-D points?

Code:
class 3DPoint 
{
    private:
        int x, y, z;

    etc...
}


3DPoint matrix = new 3DPoint[ 1000 ];
Its a little bit more organized and you can actually add alot more functionality to it later.
 
Old 03-03-2004, 01:49 AM   #4
chewysplace
Member
 
Registered: Sep 2003
Distribution: Slackware 10 w/ Kernel 2.6.8
Posts: 176

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by hypexr
shouldn't a 3 demensional array work? Why the 4th?
the 4th is to keep the information on what is contained at the coordinats:

blah[x][y][z][item]
 
Old 03-03-2004, 01:50 AM   #5
chewysplace
Member
 
Registered: Sep 2003
Distribution: Slackware 10 w/ Kernel 2.6.8
Posts: 176

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by biosx
Instead of using a 4-D array why not use a 1-D array of a data structure that holds data on 3-D points?

Code:
class 3DPoint 
{
    private:
        int x, y, z;

    etc...
}


3DPoint matrix = new 3DPoint[ 1000 ];
Its a little bit more organized and you can actually add alot more functionality to it later.
AWSOME! i'll give it a shot.
 
Old 03-03-2004, 08:24 AM   #6
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
Quote:
Originally posted by chewysplace
the 4th is to keep the information on what is contained at the coordinats:

blah[x][y][z][item]
Hrmm... I would have thought that

item = blah[x][y][z];

Unless you are saying that blah is just an array of booleans to see if a particular item exists at that location. Doesn't seem like a very efficient arrangement if that's the case, though. Even if you are designing it to have multiple items at a spot, I would think that it would be item = blah[x][y][z][i], where i is an index to the number of items at location x,y,z.

Anyway, I would definitely go with the class idea. It's much more expandable and easier to implement.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
AAARGHGHGH!!! where is the 4th CD?! bariswheel Mandriva 14 12-25-2004 08:02 AM
4th cd of Mandrake 10.0 m11p03ln Linux - Software 2 10-08-2004 11:58 AM
4th CD Location gtkmike Mandriva 2 09-06-2004 10:08 AM
4th of July newinlinux Slackware 8 06-21-2004 07:32 PM
The 4th CD?? shooter Linux - General 2 04-14-2002 09:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration