Spatial

2D Game: Fast(est) way to find x closest entities for another entity - huge amount of entities, highly dynamic

本小妞迷上赌 提交于 2019-12-03 00:08:02
I'm working on a 2D game that has a huge amount of dynamic entities. For fun's sake, let's call them soldiers, and let's say there are 50000 of them (which I just randomly thought up, it might be much more or much less :)). All these soldiers are moving every frame according to rules - think boids / flocking / steering behaviour. For each soldier, to update it's movement I need the X soldiers that are closest to the one I'm processing. What would be the best spatial hierarchy to store them to facilitate calculations like this without too much overhead ? (All entities are updated/moved every

Confused between Temporal and Spatial locality in real life code

ⅰ亾dé卋堺 提交于 2019-12-02 23:17:29
I was reading this question , I wanted to ask more about the code that he showed i.e for(i = 0; i < 20; i++) for(j = 0; j < 10; j++) a[i] = a[i]*j; The questions are, I understand temporal locality, I think that references to i and j should be temporal locality. Am I right? I also understand spatial locality, as the question I linked answers that references to a[i] should be spatial locality. Am I right? The person said, "The inner loop will call same memory address when accessing a[i] ten times so that's an example for temporal locality I guess. But is there spatial locality also in the above

Criteria SpatialRestrictions.IsWithinDistance NHibernate.Spatial

北战南征 提交于 2019-12-02 21:31:53
Has anyone implemented this, or know if it would be difficult to implement this/have any pointers? public static SpatialRelationCriterion IsWithinDistance(string propertyName, object anotherGeometry, double distance) { // TODO: Implement throw new NotImplementedException(); } from NHibernate.Spatial.Criterion.SpatialRestrictions I can use "where NHSP.Distance(PROPERTY, :point)" in hql. But want to combine this query with my existing Criteria query. for the moment I'm creating a rough polygon, and using criteria.Add(SpatialRestrictions.Intersects("PROPERTY", myPolygon)); EDIT Got a prototype

SQL Geometry find all points in a radius

这一生的挚爱 提交于 2019-12-02 21:13:49
I am fluent in SQL but new to using the SQL Geometry features. I have what is probably a very basic problem to solve, but I haven't found any good resources online that explain how to use geometry objects. (Technet is a lousy way to learn new things...) I have a collection of 2d points on a Cartesian plane, and I am trying to find all points that are within a collection of radii. I created and populated a table using syntax like: Update [Things] set [Location] = geometry::Point(@X, @Y, 0) (@X,@Y are just the x and y values, 0 is an arbitrary number shared by all objects that allows set

Correct way of finding distance between two coordinates using spatial function in MySql

﹥>﹥吖頭↗ 提交于 2019-12-02 21:12:56
I am trying to calculate distance between two locations using spatial functions in both Mysql and PostgresSQL. I have taken the latitude and longitude from Google. The details are below Location one - Lat: 42.260223; Lon: -71.800010 Location two - Lat: 42.245647; Lon: -71.802521 SQL Query used: SELECT DISTANCE(GEOMFROMTEXT('Point(42.260223 -71.800010)'),GEOMFROMTEXT('Point(42.245647 -71.802521)')) The both databases are giving the same result 0.014790703059697. But when I calculate distance in other systems the results are different. Please refer the below links http://www.zip-codes.com

Principal component analysis (PCA) of time series data: spatial and temporal pattern

不想你离开。 提交于 2019-12-02 19:39:31
Suppose I have yearly precipitation data for 100 stations from 1951 to 1980. In some papers, I find people apply PCA to the time series and then plot the spatial loadings map (with values from -1 to 1), and also plot the time series of the PCs. For example, figure 6 in https://publicaciones.unirioja.es/ojs/index.php/cig/article/view/2931/2696 is the spatial distribution of the PCs. I am using function prcomp in R and I wonder how I can do the same thing. In other words, how can I extract the "spatial pattern" and "temporal pattern" from the results of prcomp function? Thanks. set.seed(1234)

3D clustering Algorithm

余生长醉 提交于 2019-12-02 18:37:26
Problem Statement: I have the following problem: There are more than a billion points in 3D space. The goal is to find the top N points which has largest number of neighbors within given distance R. Another condition is that the distance between any two points of those top N points must be greater than R. The distribution of those points are not uniform. It is very common that certain regions of the space contain a lot of points. Goal: To find an algorithm that can scale well to many processors and has a small memory requirement. Thoughts: Normal spatial decomposition is not sufficient for

How to optimize scan of 1 huge file / table in Hive to confirm/check if lat long point is contained in a wkt geometry shape

走远了吗. 提交于 2019-12-02 13:33:12
问题 I am currently trying to associate each lat long ping from a device to its ZIP code. I have de-normalized lat long device ping data and created a cross-product/ Cartesian product join table in which each row has the ST_Point(long,lat), geometry_shape_of_ZIP and associated zip code for that geometry. for testing purpose I have around 45 million rows in the table and it'll increase in production to about 1 billion every day. Even though the data is flattened and no join conditions, the query

Find Long/Lat inside of polygon with MySQL 5.6

烂漫一生 提交于 2019-12-02 11:03:12
I have a locations table that has many rows of locations and data. There are 2 columns inside of that - Longitude and Latitude. I want to find records from that table that are found in a defined map polygon area. I have a second table that I just created based on some tutorials called polyThing which has my defined boundary... CREATE TABLE polyThing ( `ID` int auto_increment primary key, `boundary` polygon not null, `testarea` varchar(200) NOT NULL ); INSERT INTO polyThing (boundary, testarea) VALUES( PolygonFromText( 'POLYGON(( -114.018522 46.855932 , -113.997591 46.856030 , -113.997447 46

optimize nearest neighbor query on 70 million extremely high density spatial point cloud on SQL Server 2008

柔情痞子 提交于 2019-12-02 06:28:55
问题 I have about 75 million records in a SQL Server 2008 R2 Express database. Each is a lat long corresponding to some value. The table has geography column. I am trying to find one nearest neighbor for a given latitude longitude (point). I already have a query with spatial index in place. But depending on where the record is in the database, say first quarter or last quarter, the query can take about from 3 to 30 seconds to find the nearest neighbor. I feel this can be optimized to give lot