Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 QuadTree Help
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
sarge




PostPosted: Sun Dec 15, 2013 8:13 pm   Post subject: QuadTree Help

So I am confused on some of the code that follows:
Also I am new to this website so yea.
I am confused on the drawSegmentation and the paintSquares portion

Plus this code has to be done by 12/17/13

public class QuadTree
{

/** Attributes **/
MyPicture pic;
QuadNode root;
int maxLevel;
double RedT;
double GreenT;
double BlueT;
QuadNode northWest;
QuadNode southWest;
QuadNode northEast;
QuadNode southEast;


/**
* Constructor for QuadTree
* @param pic - the picture object
* @param root - the root
* @param maxLevel - the maximum level
* @param RedT - the red T
* @param GreenT - the green T
* @param BlueT - the blue T
*/
public QuadTree (MyPicture pic, QuadNode root, int maxLevel, double RedT, double GreenT, double BlueT){
this.pic = pic;
this.root = root;
this.maxLevel = maxLevel;
this.RedT = RedT;
this.GreenT = GreenT;
this.BlueT = BlueT;
this.split(root);
}

/**
* Split helper method that splits the segments represented by it into 4 QuadNode nodes
* One for each of northEast, northWest, southEast, and southWest
* @param QuadNode node
*/
public void split(QuadNode node) {
if (homogeneous(node) != true) {
node.northWest = new QuadNode(pic, node.getX(), node.getY(), node.getSideLength()/2,node.getLevel()+1, pic.simpleStatistics(node.getX(),node.getY(), node.getSideLength()));
split(northWest);
node.northEast = new QuadNode(pic, node.getX()+node.getSideLength()/2, node.getY(), node.getSideLength()/2,node.getLevel()+1, pic.simpleStatistics(node.getX(),node.getY(), node.getSideLength()));
split(northEast);
node.southWest = new QuadNode(pic, node.getX(), node.getY()+node.getSideLength()/2, node.getSideLength()/2,node.getLevel()+1, pic.simpleStatistics(node.getX(),node.getY(), node.getSideLength()));
split(southWest);
node.southEast = new QuadNode(pic, node.getX()+node.getSideLength()/2, node.getY()+node.getSideLength()/2, node.getSideLength()/2,node.getLevel()+1, pic.simpleStatistics(node.getX(),node.getY(), node.getSideLength()));
split(southEast);

}
}


public boolean homogeneous(QuadNode node){
if ((node.sigmaRed <= RedT && node.sigmaGreen <= GreenT && node.sigmaBlue <= BlueT || node.level==maxLevel || node.sideLength <= 8))
return true;
}

public boolean isLeaf() {
return northEast == null;
}

private void preorder (QuadNode root, LinkedQueue<T> queue)
{

if (root != null)
{
queue.enqueue(node);
preorder (root.getNorthEast(), queue);
preorder (root.getSouthWest(), queue);
preorder (root.getNorthWest(), queue);
preorder (root.getSouthEast(), queue);
}//if

} // method preorder

public void drawSegmentation(MyPicture pic, LinkedQueue<T> queue){
dequeue(queue);
}

public void paintSquares(){
paintSegment(int x,int y,int sideLength, double red,double green,double blue);
}
Sponsor
Sponsor
Sponsor
sponsor
sarge




PostPosted: Sun Dec 15, 2013 11:33 pm   Post subject: RE:QuadTree Help

Anyone??
Raknarg




PostPosted: Sun Dec 15, 2013 11:41 pm   Post subject: RE:QuadTree Help

I know about quadtrees but this seems a little strange without context, it's clearly missing some other parts (I'm guessing)
sarge




PostPosted: Sun Dec 15, 2013 11:44 pm   Post subject: Re: RE:QuadTree Help

Raknarg @ Sun Dec 15, 2013 11:41 pm wrote:
I know about quadtrees but this seems a little strange without context, it's clearly missing some other parts (I'm guessing)


Well there are other programs that call to this program. I am glad you know about quadtrees because in my class we never learned about them yet have to write a program using them. Basically the program has to store an 8x8 pixel image using quadtrees.
sarge




PostPosted: Sun Dec 15, 2013 11:45 pm   Post subject: RE:QuadTree Help

http://www.csd.uwo.ca/courses/CS1027b/assignments/asn4/asn4-description.html

Here is the link to the rest of the programs that are involved.
Raknarg




PostPosted: Mon Dec 16, 2013 12:10 am   Post subject: RE:QuadTree Help

Idk if he's busy but I remember Insectoid has some experience with them, you should shoot him a pm. The only think I sort of know how to do withthem is collision detection and idk if that'll be helpful here
sarge




PostPosted: Mon Dec 16, 2013 12:18 am   Post subject: RE:QuadTree Help

Nope just has to store an 8x8 pixel image into a quad tree. And everything I find online has been the collision detection. I will shoot him a pm on here; hopefully he can get back to me tonight.
Tony




PostPosted: Mon Dec 16, 2013 1:04 am   Post subject: RE:QuadTree Help

Is there a specific question about QuadTrees (or about anything, really?)

Also
Quote:

Remember that assignments are to be done individually and must be your own work.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
sarge




PostPosted: Mon Dec 16, 2013 9:05 am   Post subject: Re: RE:QuadTree Help

Tony @ Mon Dec 16, 2013 1:04 am wrote:
Is there a specific question about QuadTrees (or about anything, really?)

Also
Quote:

Remember that assignments are to be done individually and must be your own work.


Well the fact that this is a quadtree program I would say yes. But I guess you could say that I am struggling using a quadtree to store an 8x8 pixel image. In our class we never learned anything about quad trees and our professor basically said sucks to suck well to life have someone online help you out... So I have no idea where to even start a QuadTree at.
sarge




PostPosted: Mon Dec 16, 2013 12:46 pm   Post subject: RE:QuadTree Help

I got it working. Now the only problem is when I run the main it doesn't ask for me to input in arguments.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: