We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello.
I asked a similar question to this a few days ago, please see: https://forum.processing.org/two/discussion/20564/indoor-navigation-using-rfid-technology#latest - but the spec of my application has now changed.
I am new to Processing and a beginner when it comes to programming in general so apologies for my lack of correct vocabulary when it comes to explaining things.
I am trying to create an application which gives the user a top-down view of a hospital building plan and allows them to choose, from a drop down menu, where they would like to go within the hospital. Each location has predefined co-ordinates and when the user chooses that location, a line will be draw from their current location to the location they have chosen. Obviously the line that is draw cannot be straight from point to point, as that would mean the line would be cutting through 'rooms' and 'walls' etc. The lines would have to follow the 'corridors' of the hospital.
Is this possible in Processing or should I be considering different Android development programs?
Any help/tutorials to set me on my way with the code will be much appreciated.
Answers
Well, possible
But user has to enter his position A also in the ground floor plan since gps doesn't work in most buildings accurate enough
But you also need a data structure that lets you solve this problem- see path finding algorithm
Quark has a library for that iirc
@Chrisir thank you for you reply.
What if the user always starts at the same point (the entrance of the hospital). This app doesn't have to be spectacular and polished, just something that will demonstrate my idea.
What do you mean by this? Is this something I should Google?
Thanks
Google it or see Wikipedia
Quarks library is a processing extension for this problem
@Chrisir
Okay, thank you for your help :)
;-)
When the starting point is always the same and im your target list there are only 5 or 10 targets, you don't need a path finder really
Just store the points of the cross roads for each target
A full implementation would be a list of waypoints and a path finding algorithm.
If you are working with a simple list of paths you can save them as a list of lists of PVectors / points or save them as a list of PShapes.
Or you could just implement each path as a simple function that calls line over and over:
@jeremydouglass Thank you for your reply, it has really helped me make progress with this project and allowed me to learn other things!
@M_Rigby -- very glad it was helpful! Good luck with your project.
To see a PShape-based example of containing multiple child shapes -- either for storing multiple paths, or for animating a single path -- then check out the PShape example in this recent related discussion:
@jeremydouglass - Hello again. I have progressed quite far with my project but was wondering how the code you sent me could be modified so the lines were dotted lines? and also have the ellipse follow the the line paths?
Use this function, replace all "line()" calls with "dottedLine()":
Not very good, but will do the job.
@Lord_of_the_Galaxy - Thank you so much! This is fantastic and its exactly what I wanted :) Any ideas on how to get the ellipse to follow the path?
An idea will be to add all the dots of your lines to an array, then your ellipse (representing a person) will follow all the items in the array in sequence.
Kf
Look at lerp () for a smooth transition between points
@M_Rigby --
Do you mean, how can this approach be turned into an animation? It would help if you provided a simple example sketch that showed exactly what you are trying to do and where you are stuck.
One very simple approach is to put all the animation steps in a function, then call the function with an argument telling it up-to-what-point you want it to render. Cascading animation could be done manually with a switch statement that contains no breaks between case statements.
...like this:
This works. However: trying to always add a standard element (like an ellipse) at the end of the last path gets tricky when using this approach. You could add a separate switch statement with breaks just for drawing path ends. Or you could just duplicate every animation step in every case (ugh), with a separate ellipse and a
break
at the each end.This approach does work, and it supports intermediate stages that aren't cumulative if we like, and it accomplishes the goal of adding an ellipse at every step, but it has a LOT of duplicate code that makes it hard to edit and extremely error-prone!
A more robust general solution is to draw all line segments in a relative rather than absolute style by using translate statements each step of the way.
Using the style a final call to ellipse() drawn at 0,0 will always be a valid last step, because no matter which animation stage 0,0 will always refer to the end of the last line segment.
This approach is an improvement. You can combine it easily with dotted line code, for example, by putting that code in
step()
.Yet another approach would be to specify line components in an ArrayList (for example, as pairs of PVectors with x,y) and then loop through the array to render a certain number of components. This starts to make sense if you aren't hand-coding a small prototype, but instead scaling up to a system in which you want to load path data and then process it.
For animation components that are more complex (like polygons, or curves), see the second link I sent you for approaches to storing animation components as child shapes in a PShape, then looping through and showing 1, 2, 3 child shapes.
Also, for more on relative motion as a paradigm see recent related discussions of Turtle graphics.
Hi @jeremydouglass -
I'm really grateful for the code examples that you have sent to me and my application is starting to take shape. As you suggested earlier I have included my sketch example and as it stands and I feel that apart from the line animation, there a few more areas that require improvement.
Problem 1 As you will see I have a splash-screen based on a png image ("Project_SplashScreen.png") and once the splash-screen appears I really would like the ListBox not to appear on the splash-screen. I only need the ListBox to display on the second image "PS_Hospital-Floor-plan.png" (a very basic ground floor plan of the hospital), once the splash-screen disappears.
Problem 2 You will see that the ListBox has several items which represent departments in the hospital. The objective is that depending on the item selected, an animated dotted line will direct you to the particular department on the plan (each dot moving at a very small interval until the line has completed). My problem is that once the item in the ListBox is clicked, the lines do not stay on the screen long enough. I did have some partial success by using a
noLoop()
in theif()
statements within thecontrolEvent()
function which retains the lines but halts the program flow at that stage.I really need to overcome these 2 problems soon because my next challenge will be to introduce a first floor plan and have the logic repeated if the item selected (department) is located upstairs on the first floor.
If you could advise me on how to overcome the problems mentioned I'll be most grateful.
The code and the png images are attached.
Many thanks.
Again, use mills() for timing events.
Now you can make the animation last 3 seconds or 30 seconds just by saving a different variable when you click your button.
@jeremydouglass - Thank you so much, solution 1 worked perfectly.
I am working on number 2 now.
Thanks again!