coordinates

Angle between 2 GPS Coordinates

瘦欲@ 提交于 2019-12-03 07:50:55
问题 I'm working in another iPhone App that uses AR, and I'm creating my own framework, but I'm having trouble trying to get the angle of a second coordinate relative to the current device position, anyone know a good resource that could help me with this? Thanks in advance! 回答1: If the two points are close enough together, and well away from the poles, you can use some simple trig: float dy = lat2 - lat1; float dx = cosf(M_PI/180*lat1)*(long2 - long1); float angle = atan2f(dy, dx); EDIT: I forgot

Storing and Querying GPS Coordinates Effectively

我怕爱的太早我们不能终老 提交于 2019-12-03 07:36:30
问题 I want to create a large database of GPS coordinates that can be queried by saying "Return all coordinates that are within 'n' metres of [this coordinate]". I need it to be as efficient as possible so looping through all the coordinates in the database and calculating whether a coordinate is within 'n' metres wouldn't be a desired solution. Is there an easier solution? Thanks 回答1: I typically do this sort of query using lat/lon. Using spherical geometry, you can put a bounding box around a

Robust atan(y,x) on GLSL for converting XY coordinate to angle

僤鯓⒐⒋嵵緔 提交于 2019-12-03 07:25:12
问题 In GLSL (specifically 3.00 that I'm using), there are two versions of atan() : atan(y_over_x) can only return angles between -PI/2, PI/2, while atan(y/x) can take all 4 quadrants into account so the angle range covers everything from -PI, PI, much like atan2() in C++. I would like to use the second atan to convert XY coordinates to angle. However, atan() in GLSL, besides not able to handle when x = 0 , is not very stable. Especially where x is close to zero, the division can overflow

Generating multiple random (x, y) coordinates, excluding duplicates?

倖福魔咒の 提交于 2019-12-03 06:44:40
问题 I want to generate a bunch (x, y) coordinates from 0 to 2500 that excludes points that are within 200 of each other without recursion. Right now I have it check through a list of all previous values to see if any are far enough from all the others. This is really inefficient and if I need to generate a large number of points it takes forever. So how would I go about doing this? 回答1: This is a variant on Hank Ditton's suggestion that should be more efficient time- and memory-wise, especially

GLSL: gl_FragCoord issues

孤人 提交于 2019-12-03 06:26:41
I am experimenting with GLSL for OpenGL ES 2.0. I have a quad and a texture I am rendering. I can successfully do it this way: //VERTEX SHADER attribute highp vec4 vertex; attribute mediump vec2 coord0; uniform mediump mat4 worldViewProjection; varying mediump vec2 tc0; void main() { // Transforming The Vertex gl_Position = worldViewProjection * vertex; // Passing The Texture Coordinate Of Texture Unit 0 To The Fragment Shader tc0 = vec2(coord0); } //FRAGMENT SHADER varying mediump vec2 tc0; uniform sampler2D my_color_texture; void main() { gl_FragColor = texture2D(my_color_texture, tc0); } So

Efficiently finding the closest coordinate pair from a set in Python

帅比萌擦擦* 提交于 2019-12-03 06:16:36
The Problem Imagine I am stood in an airport. Given a geographic coordinate pair, how can one efficiently determine which airport I am stood in? Inputs A coordinate pair (x,y) representing the location I am stood at. A set of coordinate pairs [(a1,b1), (a2,b2)...] where each coordinate pair represents one airport. Desired Output A coordinate pair (a,b) from the set of airport coordinate pairs representing the closest airport to the point (x,y) . Inefficient Solution Here is my inefficient attempt at solving this problem. It is clearly linear in the length of the set of airports. shortest

In Objective-C (OS X), is the “global display” coordinate space used by Quartz Display Services the same as Cocoa's “screen” coordinate space?

[亡魂溺海] 提交于 2019-12-03 05:59:30
I'm attempting to create an image "loupe" for my application that can be used to inspect images at different magnification levels, and I have run into a bit of a road bump. I'm using Quartz to create a CGImageRef snapshot of a selected portion of the display my app's window is on. The problem is, the nomenclature used by all of the different OS X technologies has me really confused. The function I'm using is CGDisplayCreateImageForRect(CGDirectDisplayID display, CGRect rect) . The documentation states the CGRect rect parameter is the "rectangle, specified in display space , for the portion of

How to convert spherical coordinates to equirectangular projection coordinates?

坚强是说给别人听的谎言 提交于 2019-12-03 05:15:28
问题 Simplified question How do you convert a spherical coordinate (θ, φ) into a position (x, y) on an equirectangular projection (also called 'geographic projection')? In which: x is longitude, the horizontal position, from -180 to 180 degrees. y is latitude, the vertical position, from -90 to 90 degrees. θ is theta, the horizontal angle in degrees, a vector from (0,0,0) to a point on the surface of a sphere. φ is phi, the vertical angle in degrees, a vector from (0,0,0) to a point on the surface

Validate latitude and longitude

眉间皱痕 提交于 2019-12-03 04:45:55
问题 I want to validate the latitude and longitude. Right now, I check just so that the value is not empty, but I want a validation to check that it is a valid latidue or longitude. How do I do that? My property looks like this: public string Lat { get { return this._lat; } set { base.ValidationErrors.Remove("Lat"); if (String.IsNullOrWhiteSpace(value)) { this.ValidationErrors.Add("Lat", strings.Positions_Lat_Empty); } this._lat = value != null ? value.Trim() : null; } } public string Lng { get {

Select coordinates which fall within a radius of a central point?

情到浓时终转凉″ 提交于 2019-12-03 03:56:59
问题 I have a database of coordinates in the schema: ID:Latitude:Longitude:name:desc I've set up my google maps application to show the markers effectively on the screen. However I need to add another feature whereby the user can view all pointers that fall within the radius from a central point. How would I write up a sql statement of the kind: Select all pointers that fall within a 10 mile radius of X & Y 回答1: The SQL below should work: SELECT * FROM Table1 a WHERE ( acos(sin(a.Latitude * 0.0175