coordinates

Generating triangular/hexagonal coordinates (xyz)

家住魔仙堡 提交于 2019-11-27 17:21:10
I'm trying to come up with an iterative function that generates xyz coordinates for a hexagonal grid. With a starting hex position (say 0,0,0 for simplicity), I want to calculate the coordinates for each successive "ring" of hexagons, as illustrated here: So far, all I've managed to come up with is this (example in javascript): var radius = 3 var xyz = [0,0,0]; // for each ring for (var i = 0; i < radius; i++) { var tpRing = i*6; var tpVect = tpRing/3; // for each vector of ring for (var j = 0; j < 3; j++) { // for each tile in vector for(var k = 0; k < tpVect; k++) { xyz[0] = ???; xyz[1] = ??

Crossing axis and labels in matlab

戏子无情 提交于 2019-11-27 16:45:26
问题 I just can't find it. How to set up axis and labels in matlab so they cross at zero point, with the labels just below the axis not on left/bottom of the plot ? If I didn't make myself clear - I just want the plot to look like like we all used to draw it when in school. Axes crossing, 4 quadrants, labels right below axis, curve ... as it goes. Anyone knows how to set it up ? 回答1: You should check out two submissions on The MathWorks File Exchange: PlotAxisAtOrigin by Shanrong Zhang axescenter

Changing position of a button

与世无争的帅哥 提交于 2019-11-27 15:37:09
I have one button in an AbsoluteLayout in an XML file. From there I am able to set the (x,y) position of the button. How can I get and set the (x,y) coordinates of the button programmatically? Thanks all. You have to get a reference to you button, for example by calling findViewById() . When you got the reference to the button you can set the x and y value with button. setX() and button. setY() . .... Button myButton = (Button) findViewById(R.id.<id of the button in the layout xml file>); myButton.setX(<x value>); myButton.setY(<y value>); .... The answer you're looking for is in LayoutParams

Android sqlite sort on calculated column (co-ordinates distance)

☆樱花仙子☆ 提交于 2019-11-27 15:22:08
问题 I am using an SQLITE database to store latitudes and longitudes of locations. I want to be able to sort the results by rough distance from the current location. I already have the current location of the device as a double (lat, lng), the lat and lng in the database are also doubles. What I want is a query that will create a virtual column that I am able to sort the results by. I currently use a function to show the distance for a selected record: float pk = (float) (180/3.14159); float a1 =

Finding a set of coordinates within a certain range from latitude and longitide

不想你离开。 提交于 2019-11-27 14:15:28
问题 I am working on a project in javascript involving google maps. The goal is to figure out 16-20 coordinate points within n kilometers from a set of latitude longitude coordinates such that the 16 points if connected will form a circle around the original coordinates. The end goal is to make it so I can figure out coordinates to plot and connect on google maps to make a circle around a given set of coordinates. The code would go something like: var coordinates = Array(); function

Console App Mouse-Click X Y Coordinate Detection/Comparison

天涯浪子 提交于 2019-11-27 14:08:43
I have a game that I am working on in a C# console application, purely as practice before going on to better methods. As opposed to using something such as a Windows Forms App, which has button functionality built in, I am endeavoring to grab the cursor position (which I know how to do) and compare it to a number of area's inside a console application as defined by perhaps pixel location, but I also do not know if there is some sort of built in unit of space other than pixels (this last bit is the part I am unable to figure). P.S. I know this is in general terms, with no code already provided,

Getting the coordinates from the location I touch the touchscreen

懵懂的女人 提交于 2019-11-27 13:33:43
I try to get the coordinates from the location where I hit the touchscreen to do put a specific UIImage at this point. How can I do this? Mundi In a UIResponder subclass, such as UIView : override func touchesBegan(touches: NSSet, withEvent event: UIEvent) { let touch = touches.anyObject()! as UITouch let location = touch.locationInView(self) } This will return a CGPoint in view coordinates. Updated with Swift 3 syntax override func touchesBegan(touches: NSSet, withEvent event: UIEvent) { let touch = touches.first! let location = touch.location(in: self) } Updated with Swift 4 syntax override

Calculating coordinates given a bearing and a distance

本小妞迷上赌 提交于 2019-11-27 13:21:41
问题 I am having problems implementing the function described here here. This is my Java implementation: private static double[] pointRadialDistance(double lat1, double lon1, double radianBearing, double radialDistance) { double lat = Math.asin(Math.sin(lat1)*Math.cos(radialDistance)+Math.cos(lat1) *Math.sin(radialDistance)*Math.cos(radianBearing)); double lon; if(Math.cos(lat) == 0) { // Endpoint a pole lon=lon1; } else { lon = ((lon1-Math.asin(Math.sin(radianBearing)*Math.sin(radialDistance)

Transforming accelerometer's data from device's coordinates to real world coordinates

好久不见. 提交于 2019-11-27 12:14:20
I'm really sorry if this is a very basic question, but I have not choice but ask it: How do you translate the accelerometer data from the device coordinates to real world coordinates? I mean, assuming that the accelerometer is giving me somenting like (Ax,Ay,Az) - in device's coordinates -, what transformations should I apply to transform the values into (Ax',Ay',Az') - in real world's coordinates -, so I can use the acceleration vector in real worlds coordinates to calculate if the device is accelerating north, east, south-west,etc? I have been working around this issue during the past few

Determine if one coordinate is in radius of another

让人想犯罪 __ 提交于 2019-11-27 10:49:10
Let's say I have a Table of rows that contain coordinates. What would be the best way to pull only the rows of coordinates which are in the radius of another coordinate? To simplify my question, I'm giving the following example: Table like: Columns: Latitude, Longitude. Row1: 23.44444 24.55555 Row2: 32.44444 28.22222 Row3: 35.11111 32.12345 In an SQL statement, how do I get the rows of coordinates that are in the radius of Row3 for example? jbochi This post shows how to do this in SQL Server. And here is how to do it in MySQL: SELECT ((ACOS(SIN($lat * PI() / 180) * SIN(lat * PI() / 180) + COS(