A dynamic array of a class, inside another separate class?
Posted
by pinnacler
on Stack Overflow
See other posts from Stack Overflow
or by pinnacler
Published on 2010-05-03T03:31:48Z
Indexed on
2010/05/12
3:14 UTC
Read the original article
Hit count: 268
I'm working on a robot localization simulator and I created a class called "landmark".
The end result is going to be a robot that is always centered and always faces the top of the screen. As it turns, the birds eye view map will rotate around the robot. To accomplish this, I'm assuming I can rotate one class and have all elements inside rotate as well.
So, the landmark class has properties x,y, label, and radius. This is suppose to simulate a tree location in a forest.
To test everything, I need "forest data," and I wrote a script to generate 100 trees in a 100m x 100m area. The script automatically generates values within an acceptable range for x,y, radius. The generated data is stored in an object called tempForest and is 100x3.
Ideally, I want to create a class called "landmarks" (plural) that has 100 landmark instances inside.
How would I instantiate 100 instances of landmark in one instance of landmarks using that randomly generated data?
Ideally, I'd just type treeBeacons = landmarks(); and it would randomly populate 100 (user definable, set in config file) instances with x, y, radius data.
I'm not sure how to deal with a dynamic array of class "Landmark", inside another single class "landmarks."
Any ideas?
© Stack Overflow or respective owner