Search Results

Search found 1507 results on 61 pages for 'coordinates'.

Page 2/61 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Sort latitude and longitude coordinates into clockwise quadrangle

    - by Dave Jarvis
    Problem Users can provide up to four latitude and longitude coordinates, in any order. They do so with Google Maps. Using Google's Polygon API (v3), the coordinates they select should highlight the selected area between the four coordinates. Solutions and Searches http://stackoverflow.com/questions/242404/sort-four-points-in-clockwise-order Graham's scan seems too complicated for four coordinates Sort the coordinates into two arrays (one by latitude, the other longitude) ... then? Question How do you sort the coordinates in (counter-)clockwise order, using JavaScript? Code Here is what I have so far: // Ensures the markers are sorted: NW, NE, SE, SW function sortMarkers() { var ns = markers.slice( 0 ); var ew = markers.slice( 0 ); ew.sort( function( a, b ) { if( a.lat() < b.lat() ) { return -1; } else if( a.lat() > b.lat() ) { return 1; } return 0; }); ns.sort( function( a, b ) { if( a.lng() < b.lng() ) { return -1; } else if( a.lng() > b.lng() ) { return 1; } return 0; }); } What is a better approach? Thank you.

    Read the article

  • Change the origin coordinates in GIMP

    - by user35887
    In the GIMP image editor, as with many other computer graphics, the origin coordinates (0,0) are in the upper left corner of the image. I'm doing work with PDF documents which go by the mathematical origin of (0,0) being in the lower left corner. I'd like to flip the y-axis ruler in the gimp so that the origin is in the lower left corner. Is it possible to do this? Thanks!

    Read the article

  • How do I convert screen coordinates to between -1 and 1?

    - by bbdude95
    I'm writing a function that allows me to click on my tiles. The origin for my tiles is the center, however, the mouse's origin is the top left. I need a way to transform my mouse coordinates into my tile coordinates. Here is what I already have (but is not working): void mouseClick(int button, int state, int x, int y) { x -= 400; y -= 300; float xx = x / 100; // This gets me close but the number is still high. float yy = y / 100; // It needs to be between -1 and 1 }

    Read the article

  • Sort latitude and longitude coordinates into clockwise ordered quadrilateral

    - by Dave Jarvis
    Problem Users can provide up to four latitude and longitude coordinates, in any order. They do so with Google Maps. Using Google's Polygon API (v3), the coordinates they select should highlight the selected area between the four coordinates. Solutions and Searches http://www.geocodezip.com/map-markers_ConvexHull_Polygon.asp http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm http://stackoverflow.com/questions/2374708/how-to-sort-points-in-a-google-maps-polygon-so-that-lines-do-not-cross http://stackoverflow.com/questions/242404/sort-four-points-in-clockwise-order http://en.literateprograms.org/Quickhull_%28Javascript%29 Graham's scan seems too complicated for four coordinates Sort the coordinates into two arrays (one by latitude, the other longitude) ... then? Jarvis March algorithm? Question How do you sort the coordinates in (counter-)clockwise order, using JavaScript? Code Here is what I have so far: // Ensures the markers are sorted: NW, NE, SE, SW function sortMarkers() { var ns = markers.slice( 0 ); var ew = markers.slice( 0 ); ew.sort( function( a, b ) { if( a.position.lat() < b.position.lat() ) { return -1; } else if( a.position.lat() > b.position.lat() ) { return 1; } return 0; }); ns.sort( function( a, b ) { if( a.position.lng() < b.position.lng() ) { return -1; } else if( a.position.lng() > b.position.lng() ) { return 1; } return 0; }); var nw; var ne; var se; var sw; if( ew.indexOf( ns[0] ) > 1 ) { nw = ns[0]; } else { ne = ns[0]; } if( ew.indexOf( ns[1] ) > 1 ) { nw = ns[1]; } else { ne = ns[1]; } if( ew.indexOf( ns[2] ) > 1 ) { sw = ns[2]; } else { se = ns[2]; } if( ew.indexOf( ns[3] ) > 1 ) { sw = ns[3]; } else { se = ns[3]; } markers[0] = nw; markers[1] = ne; markers[2] = se; markers[3] = sw; } What is a better approach? The recursive Convex Hull algorithm is overkill for four points in the data set. Thank you.

    Read the article

  • Calculating bounding grid coordinates to a user click on google maps/google earth

    - by user170304
    Hello, I have a requirement to calculate the centroid or geodesic midpoint of when a user clicks in between the lat/long grid crossing. The crossing forms a square in most parts of GE and sometimes elongated rectangles. This is due to the shape of the earth of course. I'm looking for a valid mathematical formula that would allow a user to click anywhere in between this grid and then an accurate function (in Javascript or server side code) that would take an assumed grid resolution (say 1km intervals for this discussion) and the input coordinates that should return a centroid coordinate within that graticule grid. To clarify please take a look at the attached image to my google group post: http://google-earth-api.googlegroups.com/web/Picture+5.png?gda=h5oFPz8AAAD315KpovipQeBwdfGpmW3ZhBc9PTADwYa-n193hZ6AItFmHuno63c7phcEXYVuRA6ccyFKn-rNKC-d1pM%5FIdV0&gsc=sz6bbAsAAABBKF7YXWYyc4GmXg-QruHj What I need to be able to do is if a user clicks anywhere in this grid square, I need to find the centroid or center point of that grid intersection/square or at least the bounding grid coordinates (that make the square). If we assume that the grid is UTM standard and has a max resolution of 1km (or make this a parameter), I need to detect the four other points nearby and then calculating the centroid is not as difficult. I welcome any feedback you all may have and appreciate it. I don't have a simple way of letting a user click anywhere on the grid and finding the grid bounding coordinates (making a square of 4 coordinates) or the centroid / midpoint of the graticule grid square necessary. One thought is to use assumptions as much as possible using a reference such as UTM coordinate reference. If I assume that the grid is X degrees wide, can we have a pure javascript function take any input coordinate and return for me the bounding graticule coordinates in Decimal Degrees? Another thought I had was to create the grid in a geo-spatial layer to take any input coordinate and return the nearest centroid of the graticule? Does this make sense? Thanks! Omar

    Read the article

  • Find top "n" nearby coordinates.

    - by John Hamelink
    I have a coordinate. I want to find the top "n" (n being a variable value) nearest coordinates out of several thousand rows stored on a MySQL database. I also want to be able to define maximum and minimum distances between the coordinate in question and the coordinates in the database. How best am I to go about this? Would it be bonkers to use PHP as I understand the syntax much better than MySQL? If I use a MySQL function, how do I move it between databases if I choose to switch servers? How is it stored? Lastly, what is the most efficient method of getting through all these coordinates accurately - the coordinates are all relatively close to one another? Thanks for your time, John.

    Read the article

  • PHP Get Shape Coordinates From Points

    - by Ozzy
    Im sure if the title is exactly what I am trying to describe so sorry if it isnt. Ok here is what i am trying to do: What i want to do is create a function that you can enter unlimited ammount of coordinates ( the blue dots) and then it will create a shape like so and then return all coordinates the shape covers. Because this is for working with pixels, there will be no decimal coordinates. Something that can be used like so: print_r(get_coords(12,6, 23,13, 30,9, 37,24, 24,34, 25,24, 7,30, 6,15)); // ^ Will output an array of all x and y coordinates that the shape covers How would i go about doing something like this?

    Read the article

  • HTML5 canvas screen to isometric coordinate conversion

    - by ovhqe
    I am trying to create an isometric game using HTML5 canvas, but don't know how to convert HTML5 canvas screen coordinates to isometric coordinates. My code now is: var mouseX = 0; var mouseY = 0; function mouseCheck(event) { mouseX = event.pageX; mouseY = event.pageY; } which gives me canvas coordinates. But how do I convert these coordinates to isometric coordinates? I am using 16x16 tiles.

    Read the article

  • Normalized Device Coordinates to window coordinates

    - by okoman
    I just read some stuff about the theory behind 3d graphics. As I understand it, normalized device coordinates (NDC) are coordinates that describe a point in the interval from -1 to 1 on both the horizontal and vertical axis. On the other hand window coordinates describe a point somewhere between (0,0) and (width,height) of the window. So my formula to convert a point from the NDC coordinate system to the window system would be xwin = width + xndc * 0.5 * width ywin = height + ynfv * 0.5 * height The problem now is that in the OpenGL documentation for glViewport there is an other formula: xwin = ( xndc + 1 ) * width * 0.5 + x ywin = ( yndc + 1 ) * height * 0.5 + y Now I'm wondering what I am getting wrong. Especially I'm wondering what the additional "x" and "y" mean. Hope the question isn't too "not programming related", but I thought somehow it is related to graphics programming.

    Read the article

  • iPhone SDK: Get GPS coordinates from Google Maps

    - by RaYell
    In an iPhone application I'm developing I need to get GPS coordinates to perform some actions based on the values received. Users should have two possibilities of giving the location: automatically from iPhone build-in GPS by finding a specific point on a map (Google Maps) I know how to user CLLocationManager to get current position coordinates and I know how to add Google Maps using JS API. What I would like to know if how can I get coordinates for a specific point on a map that user clicks. Is that possible with UIWebView or is there any other way of getting the values I need?

    Read the article

  • Get coordinates in parent, but not in stage.

    - by Bart van Heukelom
    I know about Flash's localToGlobal and globalToLocal methods to transform coordinates from the local system to the global system, but is there a way to achieve the intermediate? To transform coordinates from an arbitrary system to any other arbitrary system? I have a clickable object inside a Sprite, and the Sprite is a child of the stage. I want to retrieve the clicked point in the Sprite.

    Read the article

  • What's the most efficient way to find barycentric coordinates?

    - by bobobobo
    In my profiler, finding barycentric coordinates is apparently somewhat of a bottleneck. I am looking to make it more efficient. It follows the method in shirley, where you compute the area of the triangles formed by embedding the point P inside the triangle. Code: Vector Triangle::getBarycentricCoordinatesAt( const Vector & P ) const { Vector bary ; // The area of a triangle is real areaABC = DOT( normal, CROSS( (b - a), (c - a) ) ) ; real areaPBC = DOT( normal, CROSS( (b - P), (c - P) ) ) ; real areaPCA = DOT( normal, CROSS( (c - P), (a - P) ) ) ; bary.x = areaPBC / areaABC ; // alpha bary.y = areaPCA / areaABC ; // beta bary.z = 1.0f - bary.x - bary.y ; // gamma return bary ; } This method works, but I'm looking for a more efficient one!

    Read the article

  • SVG - From Window coordinates to ViewBox coordinates

    - by user353072
    Hi, Basically I have an svg "SecondSVG" into an svg "FirstSVG" into an svg "MainSVG".Every svg has its own ViewBox. This page can be loaded anywhere on the screen by another page. So basically how can i find the screen x for viewBox for"SecondSVG" knowing that this svg can be loaded basically anywhere based on the calling page? event.clientX gives myself the x coordinate for the screen. If I don't know the coordinate for ViewBox of "SecondSVG" then how can I find out the x coordinate inside the ViewBox of "SecondSVG"? I am using Firefox 3.6.3 and I do have an event object from which I can extract clientX, clientY and other coordinates that are relative to the screen. However what I need are the coordinates inside the ViewBox.

    Read the article

  • Libgdx 2D Game, Random generated World of random size, how to get mouse coordinates?

    - by Solom
    I'm a noob and English is not my mothertongue, so please bear with me! I'm generating a map for a Sidescroller out of a 2D-array. That is, the array holds different values and I create blocks based on that value. Now, my problem is to match mouse coordinates on screen with the actual block the mouse is pointing at. public class GameScreen implements Screen { private static final int WIDTH = 100; private static final int HEIGHT = 70; private OrthographicCamera camera; private Rectangle glViewport; private Spritebatch spriteBatch; private Map map; private Block block; ... @Override public void show() { camera = new OrthographicCamera(WIDTH, HEIGHT); camera.position.set(WIDTH/2, HEIGHT/2, 0); glViewport = new Rectangle(0, 0, WIDTH, HEIGHT); map = new Map(16384, 256); map.printTileMap(); // Debugging only spriteBatch = new SpriteBatch(); } @Override public void render(float delta) { // Clear previous frame Gdx.gl.glClearColor(1, 1, 1, 1 ); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); GL30 gl = Gdx.graphics.getGL30(); // gl.glViewport((int) glViewport.x, (int) glViewport.y, (int) glViewport.width, (int) glViewport.height); spriteBatch.setProjectionMatrix(camera.combined); camera.update(); spriteBatch.begin(); // Draw Map this.drawMap(); // spriteBatch.flush(); spriteBatch.end(); } private void drawMap() { for(int a = 0; a < map.getHeight(); a++) { // Bounds check (y) if(camera.position.y + camera.viewportHeight < a)// || camera.position.y - camera.viewportHeight > a) break; for(int b = 0; b < map.getWidth(); b++) { // Bounds check (x) if(camera.position.x + camera.viewportWidth < b)// || camera.position.x > b) break; // Dynamic rendering via BlockManager int id = map.getTileMap()[a][b]; Block block = BlockManager.map.get(id); if(block != null) // Check if Air { block.setPosition(b, a); spriteBatch.draw(block.getTexture(), b, a, 1 ,1); } } } } As you can see, I don't use the viewport anywhere. Not sure if I need it somewhere down the road. So, the map is 16384 blocks wide. One block is 16 pixels in size. One of my naive approaches was this: if(Gdx.input.isButtonPressed(Input.Buttons.LEFT)) { Vector3 mousePos = new Vector3(); mousePos.set(Gdx.input.getX(), Gdx.input.getY(), 0); camera.unproject(mousePos); System.out.println(Math.round(mousePos.x)); // *16); // Debugging // TODO: round // map.getTileMap()[mousePos.x][mousePos.y] = 2; // Draw at mouse position } I confused myself somewhere down the road I fear. What I want to do is, update the "block" (or rather the information in the Map/2D-Array) so that in the next render() there is another block. Basically drawing on the spriteBatch g So if anyone could point me in the right direction this would be highly appreciated. Thanks!

    Read the article

  • Importing an object from Blender into a scene, rotation on X axis?

    - by Arne
    This is my situation: I save the scene with blender no export with any processing steps. Blender has x right y up -z into the scene for the view coordinates (OpenGL) I have x right y up -z into the scene for the view coordinates (OpenGl) Bleneder has x/y plane and z up as world coordinates I have x/y plane and z up as world coordinates I load the mesh with assimp directly from the blend file with absolutely no post processing. The object is rotated abount p/2 on the x-axis. Why?

    Read the article

  • Arcball 3D camera - how to convert from camera to object coordinates

    - by user38873
    I have checked multiple threads before posting, but i havent been able to figure this one out. Ok so i have been following this tutorial, but im not using glm, ive been implementing everything up until now, like lookat etc. http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Tutorial_Arcball So i can rotate with the click and drag of the mouse, but when i rotate 90º degrees around Y and then move the mouse upwards or donwwards, it rotates on the wrong axis, this problem is demonstrated on this part of the tutorial An extra trick is converting the rotation axis from camera coordinates to object coordinates. It's useful when the camera and object are placed differently. For instace, if you rotate the object by 90° on the Y axis ("turn its head" to the right), then perform a vertical move with your mouse, you make a rotation on the camera X axis, but it should become a rotation on the Z axis (plane barrel roll) for the object. By converting the axis in object coordinates, the rotation will respect that the user work in camera coordinates (WYSIWYG). To transform from camera to object coordinates, we take the inverse of the MV matrix (from the MVP matrix triplet). What i have to do acording to the tutorial is convert my axis_in_camera_coordinates to object coordinates, and the rotation is done well, but im confused on what matrix i use to do just that. The tutorial talks about converting the axis from camera to object coordinates by using the inverse of the MV. Then it shows these 3 lines of code witch i havent been able to understand. glm::mat3 camera2object = glm::inverse(glm::mat3(transforms[MODE_CAMERA]) * glm::mat3(mesh.object2world)); glm::vec3 axis_in_object_coord = camera2object * axis_in_camera_coord; So what do i aply to my calculated axis?, the inverse of what, i supose the inverse of the model view? So my question is how do you transform camera axis to object axis. Do i apply the inverse of the lookat matrix? My code: if (cur_mx != last_mx || cur_my != last_my) { va = get_arcball_vector(last_mx, last_my); vb = get_arcball_vector( cur_mx, cur_my); angle = acos(min(1.0f, dotProduct(va, vb)))*20; axis_in_camera_coord = crossProduct(va, vb); axis.x = axis_in_camera_coord[0]; axis.y = axis_in_camera_coord[1]; axis.z = axis_in_camera_coord[2]; axis.w = 1.0f; last_mx = cur_mx; last_my = cur_my; } Quaternion q = qFromAngleAxis(angle, axis); Matrix m; qGLMatrix(q,m); vi = mMultiply(m, vi); up = mMultiply(m, up); ViewMatrix = ogLookAt(vi.x, vi.y, vi.z,0,0,0,up.x,up.y,up.z);

    Read the article

  • DirectX Sphere Texture Coordinates

    - by Rushyo
    I have a sphere with per-vertex normals and I'm trying to derive the texture coordinates for the object using the algorithm: U = Asin(Norm.X) / PI + 0.5 V = Asin(Norm.Y) / PI + 0.5 With a polka dot texture, I get: Here's the same object without the texture applied: The issue I'm particuarly looking at (I know there's a few) is the misalignment of the textures. I am inclined to believe the issue resides in my use of those algorithms, as the specular highlighting (which doesn't utilise any textures but does rely on the normals being correct) appears to have no artifacts. Any ideas?

    Read the article

  • WPF Bind User Control Coordinates

    - by morsanu
    Another beginner WPF question from me :) Ok, so I have a User Control added to a Canvas. In another area of the application I have two TextBoxes that will get 2 values : X and Y. I need a two-way binding between the user control's top left corner coordinates and those 2 textboxes. I don't mind implementing a Converter or doing some calculations, but I need a push in the right direction from a more experienced WPF developer.

    Read the article

  • Determine the urban district from coordinates

    - by Michael Kowhan
    Hi, I am looking for a database that allows to find the name of an urban district from the coordinates. I have tried to use Google Maps or Open Street Map to find that information, but they do not seem to be able to deliver this data. I'm especially looking for a database for Germany Cheers, Michael

    Read the article

  • PHP Find Coordinates between two points

    - by Ozzy
    Hi all, simple question here. Lets say I have two points: point 1 x = 0 y = 0 point 2 x = 10 y = 10 How would i find out all the coordinates inbetween that programmatically, assuming there is a strait line between two points... so the above example would return: 0,0 1,1 2,2 3,3 ... 8,8 9,9 10,10 Thanks :)

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >