Quantcast

Odd behavior in move by vector

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Odd behavior in move by vector

Michael.Schneider

I am seeing something strange when I use moveByVector for a geography projection.  The test code moves at lat/long near 0.0,0.0 and my agents moved in a 100 meter grid (0,0 0.00099, 0.00099). Notice that my FROM and TO coordinates have been swapped on the first tick (tick 2).  The next tick the FROM is not the same as the TO from the pevious tick.  And after the code executes the values are swapped again.

 

The code segment below is in my agent class and is executed ever tick.

 

GeodeticCalculator gc = new GeodeticCalculator(context.getCRS());

gc.setStartingGeographicPoint(pt.x, pt.y);

gc.setDestinationGeographicPoint(currentDestination.getX(),

            currentDestination.getY());

double deg = gc.getAzimuth();

System.out.println("Azimuth " + deg);

double angle = Math.toRadians((deg+360)%360);

System.out.println("DEBUG: CGAuxAgent:tick - angle " + deg + " or "+ angle + " backToDegrees " + Math.toDegrees(angle));

context.moveByVector(this, 1.0, angle);

Coordinate newpt = context.getGeometry(this).getCoordinate();

gc.setDestinationGeographicPoint(newpt.x,newpt.y);

System.out.println(RepastEssentials.GetTickCount()+" "+name

            + " - Moved Location FROM: - " + pt.toString() +"TO: " + newpt.toString()

            + " - A distance of - " + gc.getOrthodromicDistance() + " meters");

 

In my output I see:

 

Azimuth 61.713290135073116

DEBUG: CGAuxAgent:tick - angle 61.713290135073116 or 1.0771001050955622 backToDegrees 61.71329013507313

2.0 Agent 1 - Moved Location FROM: - (5.19535662101762E-4, 2.557603982029744E-4, NaN)TO: (2.557603982029744E-4, 5.19535662101762E-4, NaN) - A distance of - 41.1011938222987 meters

 

Azimuth 92.6965058589432

DEBUG: CGAuxAgent:tick - angle 92.6965058589432 or 1.6178592323327727 backToDegrees 92.69650585894318

3.0 Coast Guard Agent 1 - Moved Location FROM: - (2.647940792624174E-4, 5.191130448808309E-4, NaN)TO: (5.191130448808309E-4, 2.647940792624174E-4, NaN) - A distance of - 40.65554203849261 meters

 

Thank you,

Mike


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://pubads.g.doubleclick.net/gampad/clk?id=1444514421&iu=/41014381
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Loading...