How to design multi level highway intersection - anylogic

So I am trying to design a multi-level highway system with the Road Traffic library in Anylogic. The highways have multiple levels and I am having trouble with depicting the difference in the levels of the roads in my model.
I looked at the help content related to RTL specifically Library Reference Guides and Tutorials but they don't mention adding grades/inclination to a road to get a multi level system.
I apologize in advance if I missed documentation related to this. But I would like to know how to do this in Anylogic.
Also, there is a Highway Junction model available in the sample models that comes with the installation and implements an increase in the z-value of the roads but I am not sure how to do that when designing the road.

When You draw road Object in RTL, in points section of the drawn road properties panel, you can set the Z value of each point of your road. So you should use more than two points to draw your road, even if it is a straight one. This way you can easily set z value of different points of your road, and build up needed levels, grades or slope of the road.
Hope this helps you.

Related

Translating GPS coordinates to map tile-like structure

I'm a complete illiterate when it comes to working with geographical data, so bear with me.
For our application we will be tracking a fairly large amount of rapidly changing points on a map. It would be nice to be able to cache the location of these points in some kind of map-tile structure so it would be easy to find all points currently in the same tile or neighbouring tiles, making it easier to quickly determine the nearest neigbours and have special logic for specific tiles, etc.
Although we're working for one specific (but already large) location, it would be nice if a solution would scale to other locations as well. Since we would only cache tiles that concern the system, would just tiling the enitre planet be the best option? The dimensions of a tile would then be measured in arc seconds/minutes, or is that a bad idea?
We already work with Postgres and this seems like something that could be done with PostGIS (is this what rasters are?), but jumping in to the documentation/tutorials without knowing what exactly I'm looking for is proving difficult. Any ideas?
PostGIS is all that you need. It can store your points in any coordinate reference system, but you'll probably be using longitude/latitude. Are your points coming from a GPS device?
PostGIS uses GIST indexing, making the search for points close to a given point quite efficient. One option you might want to look at, seeing that you are interested in tiling, is to "geohash" your points. Basically, this turns an (X,Y) coordinate pair into a single "string" with a length depending on the level of partitioning. Nearby points will have the same geohash value (= 1 tile) and are then easily identified with standard database search tools. See this answer and related question for some more considerations and an example in PostgreSQL.
You do not want to look at rasters. These are gridded data, think aerial photography or satellite images, weather maps, etc.
But if you want a more specific answer you should give some more details:
How many points? How are they collected?
Do you have large clusters?
Local? Regional? Global?
What other data does this relate to?
Pseudo table structure? Data layout?
etc
More info = better answer
Cheers, hope you get your face back

Two layers with same CRS have widely different coordinates and scales, do not line up

I have two layers.
(1) Raster layer with flood inundation depths for Vietnam
(2) Shapefile layer with administrative boundaries for Vietnam
The two layers have the same projection (4326).
I load them both onto QGIS. The raster looks good and has appropriate coordinates (e.g. 100.96, 10.47) and scale (1:7,251,734). But the shapefile is really weird. Its coordinates are something ridiculous like (870842, 1503788) and its scale is also crazy at (1:-2,147,483,648).
Of course, the two layers do not line up.
Can someone please help me out?
I suspect that a spatial reference misassignment is behind this question. It is possible to associate an impossible spatial reference. (I have done this.) The administrative boundary coordinates look like meters, not degrees - minutes.
-a look at the bounds for Vietnam here
spatatialreference.org/ref/epsg/3406/
is a place to start.
Then, trace back to the source for the administrative boundary to find the correct projected spatitial reference.
I hope this helps.
best regards,
Katie

How does routing services for OSM determine the distance between two points

I am going to design an Android application and I will be needing the distances of the pathways inside our university(pathways between buildings)
I read about OSM(OpenStreetMap) and tried it. It is a map which is editable which means anyone can contribute to that map(like a wikipedia map version).
It has many routing services that give routes and directions between two point(start and end).
There is a routing service named GraphHopper and it is very easy to use. I can just drag and drop the start and end pt and it gives the distance(km) between the two pts.
What I want to know is how did they come up with the distance?
Is the distance reliable and accurate?
Any help is greatly appreciated because I want to use the distances for my Android app and I need to know if these distances have basis.
The distance is 'accurate' in the sense that it correctly processes the existing information from OpenStreetMap and correctly adds road segments for the final route. You can just try for your local area and compare to your own knowledge.
There could be mapping errors, where a road is incorrectly mapped. And there could be also roads missing and so the router uses a detour making the path unnecessarily longer. Also there are different modes like for cars or bikes or fastest and shortest where you get a different distance between two coordinates.

Class Design: Car and Road

I'm trying to figure out the best way to design Car and Road objects for a game design I'm working on.
The idea is for AI Cars (as well as the Player controlled car) to recognize when they traverse dotted lines or straight lines on the Roads.
I'd like to be able to build a Variable Lane Road for Unity3D with the appropriate flags and sub objects so that the Cars recognize where they are and when and how they traverse or take turns etc' etc'
For example, a Road can have a single direction or be in both directions.
For each direction there can be a number of lanes. Lanes allow cars to overtake each other (meaning a dotted line between the lanes).
If it's a bi directional road, then there's a line between the two lanes - optionally and ideally, if there's more than one lane on any of the directions, then the line that separates the directional lanes is straight.
By default, there should be a flag that draws the line according to an isOvertakingAllowed boolean flag.
The most important part is that the Car objects need to know what lane they are on or if they are on a lane separating line, and what type this separation is (overtaking allowed or not).
That's the hard part, to me.
Any help is appreciated.
I would recommend you implement a Lane, which have a direction of travel. Then implement a Road which has a collection of points, a path defining it's shape, and distance, and a collection of Lane objects that follow that path. Whether the road is one-way or two-way becomes a matter of which, and how many lanes they have.
In this case, a Car travels on a Road in a given direction, following the lane that it's in. It can only switch to other lanes that have compatible directions of travel (i.e. that are heading in the same direction as the car), unless the car turns around.
You might also have a special point in a Road called an Intersection which is a connection point for multiple Lanes, and somehow specify which Lanes a Car can transition to and from when it's at the Intersection.
That's a rough outline, but I think those are the basic relationships between the objects that you present, and should get you started.
There is an article on gamasutra with description of the model that was used for opencity, and how the different agents (standard car, racing car, pedestrian...) could use it. It may gives you some pointers or ideas.

Jelly physics 3d

I want to ask about jelly physics ( http://www.youtube.com/watch?v=I74rJFB_W1k ), where I can find some good place to start making things like that ? I want to make simulation of cars crash and I want use this jelly physics, but I can't find a lot about them. I don't want use existing physics engine, I want write my own :)
Something like what you see in the video you linked to could be accomplished with a mass-spring system. However, as you vary the number of masses and springs, keeping your spring constants the same, you will get wildly varying results. In short, mass-spring systems are not good approximations of a continuum of matter.
Typically, these sorts of animations are created using what is called the Finite Element Method (FEM). The FEM does converge to a continuum, which is nice. And although it does require a bit more know-how than a mass-spring system, it really isn't too bad. The basic idea, derived from the study of continuum mechanics, can be put this way:
Break the volume of your object up into many small pieces (elements), usually tetrahedra. Let's call the entire collection of these elements the mesh. You'll actually want to make two copies of this mesh. Label one the "rest" mesh, and the other the "world" mesh. I'll tell you why next.
For each tetrahedron in your world mesh, measure how deformed it is relative to its corresponding rest tetrahedron. The measure of how deformed it is is called "strain". This is typically accomplished by first measuring what is known as the deformation gradient (often denoted F). There are several good papers that describe how to do this. Once you have F, one very typical way to define the strain (e) is:
e = 1/2(F^T * F) - I. This is known as Green's strain. It is invariant to rotations, which makes it very convenient.
Using the properties of the material you are trying to simulate (gelatin, rubber, steel, etc.), and using the strain you measured in the step above, derive the "stress" of each tetrahdron.
For each tetrahedron, visit each node (vertex, corner, point (these all mean the same thing)) and average the area-weighted normal vectors (in the rest shape) of the three triangular faces that share that node. Multiply the tetrahedron's stress by that averaged vector, and there's the elastic force acting on that node due to the stress of that tetrahedron. Of course, each node could potentially belong to multiple tetrahedra, so you'll want to be able to sum up these forces.
Integrate! There are easy ways to do this, and hard ways. Either way, you'll want to loop over every node in your world mesh and divide its forces by its mass to determine its acceleration. The easy way to proceed from here is to:
Multiply its acceleration by some small time value dt. This gives you a change in velocity, dv.
Add dv to the node's current velocity to get a new total velocity.
Multiply that velocity by dt to get a change in position, dx.
Add dx to the node's current position to get a new position.
This approach is known as explicit forward Euler integration. You will have to use very small values of dt to get it to work without blowing up, but it is so easy to implement that it works well as a starting point.
Repeat steps 2 through 5 for as long as you want.
I've left out a lot of details and fancy extras, but hopefully you can infer a lot of what I've left out. Here is a link to some instructions I used the first time I did this. The webpage contains some useful pseudocode, as well as links to some relevant material.
http://sealab.cs.utah.edu/Courses/CS6967-F08/Project-2/
The following link is also very useful:
http://sealab.cs.utah.edu/Courses/CS6967-F08/FE-notes.pdf
This is a really fun topic, and I wish you the best of luck! If you get stuck, just drop me a comment.
That rolling jelly cube video was made with Blender, which uses the Bullet physics engine for soft body simulation. The bullet documentation in general is very sparse and for soft body dynamics almost nonexistent. You're best bet would be to read the source code.
Then write your own version ;)
Here is a page with some pretty good tutorials on it. The one you are looking for is probably in the (inverse) Kinematics and Mass & Spring Models sections.
Hint: A jelly can be seen as a 3 dimensional cloth ;-)
Also, try having a look at the search results for spring pressure soft body model - they might get you going in the right direction :-)
See this guy's page Maciej Matyka, topic of soft body
Unfortunately 2d only but might be something to start with is JellyPhysics and JellyCar