« first day (3292 days earlier)      last day (1639 days later) » 

8:00 AM
this sort of thing can really get confusing
 
Oh.
Would you be able to tell me a better way of doing what I'm doing? I don't mind re-writing everything as well.
 
I find what works for me in cases like this is to separate tasks
have a model which has all the information you require to draw the rooms and whatnot
 
Yup, done that.
 
the model would also have coordinates for the enter/exit of each room
 
Now working on showing the path.
 
8:01 AM
and it would have coordinates representing crossways in hallways
 
Could you show me some sample data for that
For the simple example I provided
 
once you have this model, you should be able to pass it to a function and A) Draw the rooms B) draw a path from two separate points in your graph
@HassanAlthaf well in your map example that you gave, I don't see any exit or entry
but lets suppose you have the meeting room exit at the bottom of the room
The entry to the pantry is at the top of the hallway on the left
you need three points. The exit/entry of meeting room, the exit/entry of pantry, and the point where the hallway meets
according to your graph, there is no direct path from exit/entry of meeting room to exit/entry of pantry
so your algorithm searches all adjacent nodes
all adjacent nodes search their adjacent nodes, etc. until you find the path to the pantry
now you have the coordinates of all three points, so just draw a line connecting them
 
Oh
I think I kind of understand now.
 
if you want to get more sophisticated, you'd also consider distances
 
Yes, I need to.
 
8:05 AM
say, there are two paths, then you'd favor the one that's shortest
 
I want to aim to find at least one path first.
 
the path system needs to know only - coordinates and which node is connected to which
 
Then I can work on finding the shortest, right?
 
the rooms need to have all the rectangles and whatnot to show the rooms to the user
and your model has both :P
 
haha, dont mind my model, I just started today morning.
took me 1-2 hours to write up all this.
 
8:06 AM
@HassanAlthaf I think that would be wise, yes
if you want the shortest, you'll need to search all nodes, not just stop at the first you find
 
I'm guessing for the shortest, I could
Find the possible routes
 
could be that you need to jump only 2 nodes to get from A to B, but it could be longer than 3 nodes from A to B
 
Then find the average of
the coordinates of the points I go through
?
I mean the difference in coordinats
 
find all routes connecting them, and then pick the one that is shortest
 
Yeah, basically an average of distance between all the points?
Would that work?
 
8:09 AM
not sure what you mean by that
 
I find the coordinates
of all the nodes I need to go past
 
If you find a path connecting A to B and B to C, then the total distance is the distance from A to B and then from B to C
 
I find the average Delta X and Average Delta Y
 
hmm, no
 
8:10 AM
if you do that, you'll calculate the direct distance between A and C
in which case any route is "best"
you need to know if one particular route is longer than another
 
oh yea, true LOL
total delta X and total delta Y
find their average, and compare the averages?
 
no, use the distance formula
 
i think I will be able to figure that out if nodes work.
But one question,
 
you have coordinate x0, y0 and coordinate x1, y1. The distance is just (x0-x1)^2 + (y0-y1)^2
 
so it gose
 
8:13 AM
technically you'd need to square that, but it doesn't make a difference if the point is merely to know if one is longer than another
you sum distances from point 1 to point 2, and then from point 2 to point 3, etc. and that's the distance of one path
 
(x0-x1-xn)^2 + (y0-y1-yn)^2
That would work right?
 
xn and yn are averages?
I don't know what that would do to the calculation, but I don't think that's what you want to do
 
no they are not.
additional coordinates of nodes
 
Hassan, did you have seen the concept "graph network" and Dijkstra shortest path algorithm?
 
0..1...2....3....4...n
@KarelG Unfortunately I haven't.
 
8:15 AM
do you have time for some research? :P
 
So, if lets say have an SVG,
@KarelG Yes, I allocate 2 hours everyday for research.
 
would be worth looking into
dijkstra was king for this kinda thing
 
try to study both concepts. It will be a greater help for in the future when you have to work for a similar project
 
For sure
 
especially the graph network has many applications
 
8:16 AM
I have heard about Shortest Path algorithm
But haven't really learnt it
 
that's from Dijkstra :P
 
I can't even read the name haha
So, in SVG,
 
you need to keep expanding adjacent nodes (avoiding nodes already visited) until you hit the node you're looking for
if you never find the node you're looking for, then it isn't connected in your graph
 
if you've found it, then you calculate the distance of all points in your graph
and now you have a path with a distance
get all such paths and their distances and you can know which is best
take the best path, draw a line between all coordinates, and there you have it :)
 
8:18 AM
Thank you so much, so I basically need to get the point working
*points work
and then I can just apply the algorithm on those
 
the distance is arbitrary, but in your case, it represents an actual traversable distance
 
So for a multi-storey building
I would find the nearest elevator
Use that
 
if the lines will be only vertical or horizontal, then the distance is just the vertical or horizontal distance
 
ANd then from the elevator to the destination
 
then you'll also have to know if you're on the same floor. If you're not, then the path should be to the elevator of that same floor
and then from the elevator of the floor having that room
 
8:20 AM
That should be do-able.
If I can figure out finding shortest path
so, in SVG
how would I represent nodes?
 
you'd have coordinates. In svg that would probably be best represented with a line between coordinates of your path?
 
oh, so i wouldnt insert anything in SVG
I would just have coordinates of the doors
in my model
and the nodes
and then i do my calculation
 
the coordinates could also be useful to know how to draw the path in svg
they could double as this
 
you're a genius man
 
:)
 
8:22 AM
i hope i can be a good developer like you one day
 
I'm sure you will, man. You're already far more advanced than I was starting off
 
Thank you man, this is my first job.
I'm currently a second year graduate, donig mandatory internship
 
But word to the wise: make it work without all the extra features
you can add the elevator in later
 
Yes, I studied that concept
Decomposition
Is it the right word?
 
@Neil eh ?
 
8:24 AM
trying to consider everything at once is a disaster waiting to happen
 
Hahahaha true that.
 
just put it as a node to the network
 
Makes you confused.
 
when he needs room X, check in an array on which floor it is
if floor is different, just navigate to elevator
 
@KarelG ok, but if the question is, "How to get from A to B?" and the answer to that question includes figuring out if the elevator needs to be used, it can wait..
 
8:24 AM
KarelG
 
just make B the elevator neil
 
don't listen to him. Start simple.
 
when he is on other level, make elevator = A and B = yours destination
 
Here's what I have in mind, could you guys give me some advice
My bad
 
no problem, just put it in a pastebin
 
8:26 AM
{
    ....
    door: {
        // coordinates
    }
}
For every block
I plan to do that
Each block has a unique ID.
 
yeah, seems like a good idea
 
good
 
consider you may also want multiple entries/exits
 
When I add each block, I populate an object into an array that holds door coordinates and the key to be the unique ID
 
but make it as an array
 
8:27 AM
again, worry about that later, but consider that may be something you have to work in
 
so when I need to find distance between block X and Y
I mean the nodes to go through
 
@HassanAlthaf I think it's a good idea to associate room ID with its door coordinates
you want to be able to find door coordinates given a room id
 
I can't understand how would I find the adjacent coordinates if I have another array of nodes on the hallway
 
that's the tricky part :P
when they add the room, you need to know the hallway it attaches to
or vice versa, when they add the hallway, you need to connect the node of the hallway to the door
you can't just search for all nearby coordinates and say they all attach
 
Oh, could you give me some advice on how to represent that data?
I'm sure if I can figure that out, I should be able to solve this problem.
 
8:30 AM
I don't know the interface you're using, but if I had to make that interface, I would make it so that a hallway snaps to an existing room or a room snaps to an existing hallway
in such a way as to introduce a door where they meet
 
It's basically writing JS Objects
 
if you know that information, then you can make that connection yourself
 
That's our interface for now
We plan to make a GUI editor for that later after we're done with this.
 
you'll need to create a hallway object similar to a room, but with its "door" coordinates in the center
 
OHHHHH
I think I know how.
 
8:32 AM
and then you'll need to have a way to say that a particular door of a room connects to a hallway
or a hallway could have two "doors" at the start and at the end of the hallway
adding a room in between would mean saying the door connects to the entry and exit of the hallway
and other hallways connect via their "entry and exit" door
and in this way everything is connected
 
Oh
So, I was visualizing this
[0,0] [100,0]

[0,20] [100,20]
I have such rectangle with 4 points.
That would be the hallway.
 
the model should represent a hallway as two points in my humble opinion
 
Lets say I had the door at 10,0
 
with a certain thickness
 
I did 4 because
 
8:36 AM
but there is also more than one way to approach this
 
Then we'd know in the hallway
To turn right or left
So if I was to turn right given I was facing 9 o'clock
I'd have my door at 10,0
If I was to turn left, I'd do 10,20
Does this seem like a good idea?
 
I'd think that would be harder to do it that way
 
Oh.
two points then?
 
but again, my thing is to make it work very simply at first, then add to it
 
[0, 10], [100, 10]
 
8:38 AM
two points and a thickness is the same as four points really
 
Would have a line in the middle of the corridor
true dat lol
 
yeah, I would do the path so that it always lies in the middle
 
neil, that approach is not always the right one
 
but if that changed in the future, then it would be just a matter of adding four points in the path, not just two
 
I'm guessing I can code a binary tree
 
8:39 AM
if you don't write for expandability then you are sucked if features has to be changed
(that is why I asked to turn door to an array
 
oh i guess not
@KarelG How would I do that?
 
@KarelG Well if you noticed, I'm the one who did suggest that there may eventually be multiple doors :P
 
@HassanAlthaf edit that to
 
oh make door to an array
 
{
    ....
    doors: [{ // coordinates }, { // coordinate other door }]
    }
}
just give it one object currently
 
8:40 AM
Btw
 
if more doors has to be added, it is a simple addition to the array
 
This object represents one block
So Cafeteria would have one set of coordinates
for door
 
only one door of the start room has to meet any of the doors of the destination room
 
Yes, I do plan to add multiple doors in a block
Because of requiremetns.
 
start with one, again, but yeah, plan on being an array
 
8:42 AM
Yes, that sounds easier to start with.
I have a month to tackle this section, so I can take it slow and easy instead of fast and confused
So, you were saying make a graph of the hallway.
How do I represent hallway points
 
to find the optimal path, you only need connected nodes
 
Goto the nearest junction?
 
so yes, it would make sense to represent using two nodes
when you exit a room, you're in a hallway in the middle
 
if done properly, it connects to hallway nodes on the left and right
 
8:44 AM
Yes, they would share common coordinates
 
you don't need to know which is faster, you only need to find out which takes you to your destination to start
you can calculate distance after
they're two separate problems in other words
 
[[0, 10], [100, 10]] [[100,10, 120,10]]
So to find the nearest junction
I would find in my array for a junction that has similar x and y coordinates
would that be a good idea?
 
you wouldn't find the nearest junction
door of meeting room connects to hallway nodes A and B
 
your algorithm would search A, and B, and all adjacent nodes of A, and B, and all adjacent nodes of the adjacent nodes, etc.
think of the "door" as a node on its own
in the middle of the hallway
 
8:48 AM
Ok, it sounds possible to do
 
also because before you can get to the destination room, you must always walk into the hallway
 
Adjacent nodes sound easy to fin
Let me work on that first.
 
when you draw it later, it will also be easier
 
Find the first A and B
 
you draw starting from the outside of the door
and not, say, in the middle of the hallway it's connected to
 
8:49 AM
Yes
Let me try that out really quick, should take me a few mins
 
user8732191
Hello, Neil. Thank you so much for the explanation. I understood that completely.
 
@NishantArora my mom got teacher of the year. I like to think I inherited something from that :)
 
user8732191
Yes, absolutely you do bro..
 
user8732191
and I hope that someday I get the talent as well like you do
 
user8732191
Bro can I ask you one more question if you dont mind?
 
8:59 AM
So, I've written code to add doors
Red dots represent doors.
I'm going to add junction points
 

« first day (3292 days earlier)      last day (1639 days later) »