coordinates

How to get pixel coordinates of a pixel inside an html5 canvas

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 09:22:59
问题 I know that you can get the value of each pixel inside the html5 Canvas using getImageData() and .data() but is there a way to get their coordinates and not just their values? 回答1: var w = ctx.canvas.width, h = ctx.canvas.height; var id = ctx.getImageData(0,0,w,h); var d = id.data; for (var y=0;y<h;++y){ for (var x=0;x<w;++x){ var i=(y*w+x)*4; var r=d[i],g=d[i+1],b=d[i+2],a=d[i+3]; } } It's just as easy to derive the x/y from the index while looping through the image data array, or to add in

Find the nearest X,Y coordinate using R

丶灬走出姿态 提交于 2019-12-12 08:37:28
问题 I'm just starting to learn R but would like project done sooner rather than later. It's rather simple: I have an X column and a Y column consisting of X coordinates and Y coordinates. (Working in the NAD27 coordinate system). Going from the first coordinate, I'd like to find the nearest point within the data set and then move onto the next coordinate and find it's nearest point within the same data set. Ideally, it would go through each point and determine the closest point. point x y 1

Matlab: convert global coordinates to figure coordinates

泄露秘密 提交于 2019-12-12 08:14:25
问题 If I get coordinates via coords = get(0,'PointerLocation'); How can I convert them into points gotten via ginput ? i.e, I would like to get the same values from coords = get(0,'PointerLocation'); coords=someConversion(coords); As I would have gotten by calling coords=ginput(1); And clicking inside the figure in the same spot as the mouse was in the previous bit of code. 回答1: Here's an example of how you can do this conversion... Let's say you have a figure, and that figure contains an axes

How to get same co-ordinates for image for all resolutions in android?

我的未来我决定 提交于 2019-12-12 08:03:49
问题 I stucked with getting x & y co-ordinates of an image for all resolutions. 320, for devices with screen configurations such as: 240x320 ldpi (QVGA handset) 320x480 mdpi (handset) 480x800 hdpi (high density handset) 480, for screens such as 480x800 mdpi (tablet/handset). 600, for screens such as 600x1024 mdpi (7" tablet). 720, for screens such as 720x1280 mdpi (10" tablet). I have created my image view with original size of an image like 1500 x 1119. When i touched the image i can get the co

iPhone correct landscape window coordinates

百般思念 提交于 2019-12-12 07:55:00
问题 I am trying to get the window coordinates of a table view using the following code: [self.tableView.superview convertRect:self.tableView.frame toView:nil] It reports the correct coordinates while in portrait mode, but when I rotate to landscape it no longer reports correct coordinates. First off, it flips the x, y coordinates and the width and height. That's not really the problem though. The real problem is that the coordinates are incorrect. In portrait the window coordinates for the table

Convert decimal coordinates to Degrees, Minutes & Seconds by c#

混江龙づ霸主 提交于 2019-12-12 07:23:32
问题 Has anyone know simple short code to convert this without use additional libraries ? 回答1: Like this: double coord = 59.345235; int sec = (int)Math.Round(coord * 3600); int deg = sec / 3600; sec = Math.Abs(sec % 3600); int min = sec / 60; sec %= 60; Edit: Added an Abs call so that it works for negative angles also. 回答2: you could use timespan: (tricky but it works) double coord = 123.312312; var ts = TimeSpan.FromHours(Math.Abs(coord)) int degrees = Math.Sign(coord) * Math.Floor(ts.TotalHours)

Leaflet separate lines

﹥>﹥吖頭↗ 提交于 2019-12-12 06:16:53
问题 I am trying to plot lines using leaflet, however I am encountering some difficulties in separating the segment. I have an object that looks like this > head(trips, n=15) time.start time.end long.start long.end lat.start lat.end distance time.diff speed color 1 1476450598 1476450713 9.03913 9.03924 45.61335 45.61362 31.25292 115 0.9783524 green 2 1476450713 1476450727 9.03924 9.03995 45.61362 45.61365 55.38651 14 14.2422459 green 3 1476450727 1476450751 9.03995 9.04005 45.61365 45.61340 28

Am I converting local space to world space coordinates properly?

血红的双手。 提交于 2019-12-12 06:13:10
问题 I'm trying to create a bone and IK system. Below is the method that is recursive and that calculates the absolute positions and absolute angles of each bone. I call it with the root bone and zero'd parameters. It works fine, but when I try to use CCD IK I get discrepancies between the resulting end point and the calculated one. Therefore maybe I'm doing this wrong even though it works. Thanks void Skeleton::_updateBones( Bone* root,float realStartX, float realStartY, float realStartAngle ) {

iPhone Simulator providing location results

筅森魡賤 提交于 2019-12-12 05:45:53
问题 I am using iOS SDK 4.2 and followed this tutorial: http://mobileorchard.com/hello-there-a-corelocation-tutorial/, and got some GPS logs happening on the console using both iPhone and iPad. Then I ran it on the simulator to test other features and the CoreLocation logs were hitting the locationManager:didFailWithError: method which is fair because the MacBookPro (OSX 10.6.6) has no GPS functionality... or so I thought. This morning I tested it on the iPad again at work instead of at home and

Swift 3.0 Get User Location Coordinates from Different View Controller

99封情书 提交于 2019-12-12 05:26:20
问题 I have two view controllers - one with the mapView that is able to obtain user location coordinations through locationManager, and a second VC that I wish to be able to pull these user coordinates. First VC: MapView func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { var coordinatesOfUser = locations.last?.coordinate print("The value of usercoordinates are \(coordinatesOfUser)") // here I want to be able to pull this variable, coordinatesOfUser if