3D array lattice access relative coordinates
in
Programming Questions
•
7 months ago
Hello,
I hope someone can help me with my question.
At the moment I have a multi-agent system in a 2D lattice. Sites within the lattice correspond to a 2D array. Each agent samples lattive values from within this array based on its current position (x,y) and current heading angle. Each agent has a motor step, where it moves forwards in its current direction by a value 'step'.
Each agent also has a sensory step. In the sensory step each agent samples values from the 2D lattice from its sensors
which are offset from the agent's current position. For example the agent can sample two values from a front left sensor and front right sensor (imagine holding your arms out in front of you and sampling the values at the locations where your hands are). These sensor positions can be specified with an offset distance (the length of your arms) and an offset angle, relative to the current forward position .
This all works fine in 2D, based on x,y position and orientation angle.
However I am now trying to implement the system in a 3D lattice.
Does anyone know of a library where, given the current x,y,z position and current pitch and heading angles, I can call a method which returns the values from indices of a 3D array corresponding to the locations of offset angles and distances, relative to current position,heading and pitch angles, such as:
leftsensor = getLatticeValue(curx, cury, curx, curpitch, curheading, desiredoffsetdist, desiredoffsetpitch, desiredoffsetheading)
where desiredoffsetdist is the desired offset distance from current position
where desiredoffsetpitch is the offset in pitch angle required
where desiredoffsetheading is the offset in heading angle required
Depending on the values of all sensor values returned the agent will rotate towards the direction of the strongest sensor. So if, for example, the left sensor has the strongest value the agent will then rotate left by a fixed value.
something like:
newposition = rotateLeft(angle)
where newposition is a structure containing x,y,z lattice reference
Again, the motor behaviour should move the agent forwards in its current direction.
Just to stress a couple of points:
- I am not trying to draw the world in 3d, or rotate the world in 3d
- I am just trying to access values from a 3d array relative to, and offset from, an agent's current position, heading and pitch.
Thanks for any help.
polyDon.
I hope someone can help me with my question.
At the moment I have a multi-agent system in a 2D lattice. Sites within the lattice correspond to a 2D array. Each agent samples lattive values from within this array based on its current position (x,y) and current heading angle. Each agent has a motor step, where it moves forwards in its current direction by a value 'step'.
Each agent also has a sensory step. In the sensory step each agent samples values from the 2D lattice from its sensors
which are offset from the agent's current position. For example the agent can sample two values from a front left sensor and front right sensor (imagine holding your arms out in front of you and sampling the values at the locations where your hands are). These sensor positions can be specified with an offset distance (the length of your arms) and an offset angle, relative to the current forward position .
This all works fine in 2D, based on x,y position and orientation angle.
However I am now trying to implement the system in a 3D lattice.
Does anyone know of a library where, given the current x,y,z position and current pitch and heading angles, I can call a method which returns the values from indices of a 3D array corresponding to the locations of offset angles and distances, relative to current position,heading and pitch angles, such as:
leftsensor = getLatticeValue(curx, cury, curx, curpitch, curheading, desiredoffsetdist, desiredoffsetpitch, desiredoffsetheading)
where desiredoffsetdist is the desired offset distance from current position
where desiredoffsetpitch is the offset in pitch angle required
where desiredoffsetheading is the offset in heading angle required
Depending on the values of all sensor values returned the agent will rotate towards the direction of the strongest sensor. So if, for example, the left sensor has the strongest value the agent will then rotate left by a fixed value.
something like:
newposition = rotateLeft(angle)
where newposition is a structure containing x,y,z lattice reference
Again, the motor behaviour should move the agent forwards in its current direction.
Just to stress a couple of points:
- I am not trying to draw the world in 3d, or rotate the world in 3d
- I am just trying to access values from a 3d array relative to, and offset from, an agent's current position, heading and pitch.
Thanks for any help.
polyDon.
1