我想在javascript中获取ipad上触摸事件的坐标.我该怎么做?
我正在尝试绘制多边形,并且希望能够单击我的框架以获取MouseCoordinates,以便更快地将mental Image转换为x/y值.
我正在使用
System.out.println("("+ MouseInfo.getPointerInfo().getLocation().x +",
"+ MouseInfo.getPointerInfo().getLocation().y +")");
Run Code Online (Sandbox Code Playgroud)
但这给了我相对于我的实际屏幕的坐标,而不是我的java窗口.
如何使坐标相对于Java窗口显示?
我有两个叫做A和B的3D矢量,它们都只有一个3D位置.我知道如何通过以下方式找到沿着单位圆的角度(0-360度)和atan2函数:
编辑:(我的atan2函数没有意义,现在它应该找到2个向量之间的"y角度"):
toDegrees(atan2(A.x-B.x,A.z-B.z))+180
Run Code Online (Sandbox Code Playgroud)
但是这给了我两个向量之间的Y角.我需要找到它们之间的X角.它与使用x,y和z位置值有关.不仅仅是x和z,因为它给出了两个向量之间的Y角.我需要X角,我知道它听起来很模糊,但我不知道如何解释.例如,如果你向上或向下看而不是旋转x轴,你可能在3D空间中有一个摄像头.但是现在我需要获得2个向量之间的"上/下"角度.如果我沿y轴旋转3D相机,则x轴不会改变.因此,与2个载体,不管是什么"Y-角"是他们之间,2个向量之间的x角度西港岛线留如果y角变化,同样因为它的"向上/向下"的角度,像在卡马拉.
请帮忙?我只需要一行数学/伪代码或解释.:)
我想做这里显示的例子.它在我的机器上运行得非常好.问题是,我无法将节点的坐标作为存储在变量pos中某处的数组.我该怎么做呢?
在此先感谢您的回复!
我在UIImageView中显示图像,我想将坐标转换为x/y值,以便我可以在此图像上显示城市.这是我根据我的研究尝试的:
CGFloat height = mapView.frame.size.height;
CGFloat width = mapView.frame.size.width;
int x = (int) ((width/360.0) * (180 + 8.242493)); // Mainz lon
int y = (int) ((height/180.0) * (90 - 49.993615)); // Mainz lat
NSLog(@"x: %i y: %i", x, y);
PinView *pinView = [[PinView alloc]initPinViewWithPoint:x andY:y];
[self.view addSubview:pinView];
Run Code Online (Sandbox Code Playgroud)
这给了我167作为x和y = 104但这个例子应该有x = 73和y = 294的值.
mapView是我的UIImageView,只是为了澄清.
所以我的第二次尝试是使用MKMapKit:
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(49.993615, 8.242493);
MKMapPoint point = MKMapPointForCoordinate(coord);
NSLog(@"x is %f and y is %f",point.x,point.y);
Run Code Online (Sandbox Code Playgroud)
但这给了我一些非常奇怪的值:x = 140363776.241755,y是91045888.536491.
所以你知道我必须做些什么才能使这个工作吗?
非常感谢!
(使用MATLAB)我有一个大的坐标矩阵和一个大的稀疏邻接矩阵,其坐标相互连接.我曾经问过SO,如何在这个SO问题中有效地计算这些距离,但我现在遇到了内存问题,这是一个更严重的问题.
我使用这个MATLAB函数来计算距离矩阵,Dists = pdist2(fruchterman_graph(:,:),fruchterman_graph(:,:),'euclidean');但它在速度和最终内存的大型网络上都失败了.
这是仅在小图表(不是数十万)上运行的代码:
coordinate = kamada_graph;
[n, d] = size(kamada_graph);
assert(d == 2);
resi = sparse(adj* spdiags((1:n)',0,n,n));
resj = sparse(spdiags((1:n)',0,n,n) * adj);
res = sparse(n,n);
f = find(adj);
res(f) = sqrt((coordinate(resi(f), 1) - coordinate(resj(f), 1)) .^ 2 +...
(coordinate(resi(f), 2) - coordinate(resj(f), 2)) .^ 2);
Run Code Online (Sandbox Code Playgroud)
这在大图上创建
??? 使用==>发现错误Matrix太大而无法返回线性索引.
使用[i,j] = find(S)用于稀疏矩阵.
在==> modularize_graphs时出错49[f] = find(adj);
我更改了被称为的行:
[i,j] = find(ajd);
res(i,j) = sqrt((coordinate(resi(i,j), 1) …Run Code Online (Sandbox Code Playgroud) 我正在使用GenomicRange R包.我有一个像这样的输入文件:
dvex108056 + 87 206
dvex108056 + 87 226
dvex108056 - 101 240
dvex108056 - 104 240
dvex108056 - 59 188
dvex108056 - 68 197
dvex108056 - 70 208
dvex108056 - 75 211
dvex108056 - 78 217
dvex108056 - 79 218
dvex108056 - 84 223
dvex108056 - 85 220
dvex108056 - 87 226
dvex108056 - 88 226
dvex108056 - 88 227
dvex108056 - 91 210
dvex108056 - 91 230
dvex114041 - 6255 6383
dvex144086 + 2557 2678
dvex144086 + …Run Code Online (Sandbox Code Playgroud) 如何计算经度和纬度坐标以在用户位置周围创建1英里半径?我不介意它需要多少个坐标,但是我想在一个位置周围创建一个圆形半径.
例如:
如果用户的位置是=
Latitude: 44.947 Longitude: -93.098
Run Code Online (Sandbox Code Playgroud)
然后,我如何确定8组经度和纬度坐标在上述位置周围创建1英里半径.
(上面例子中的8是斜体,因为我不介意它是否小于或大于8)
我该怎么做呢?
代码到目前为止:
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
double longitude = location.getLongitude();
double latitude = location.getLatitude();
Run Code Online (Sandbox Code Playgroud)
虽然我很高兴人们正在努力帮助,但下面给出的答案并没有回答这个问题.
我想扩展一个我在Stackoverflow上讨论过的问题.它正在处理2D numpy数组,我想用三维数组做同样的事情.
我想将2D数组的元素"移动"到新坐标,这些坐标存储在其他2个数组中.我希望自动化这个,因为实际上我的阵列很大(400x200x100).有些值不会找到他的坐标并且不会被使用,其中一些坐标被屏蔽,我在下面的例子中通过使用值0指示.如果坐标被屏蔽,我想要重新洗牌的数组中的元素将不会使用.
import numpy as np
#My new coordinates in X and Y directions
mx = np.array([[[ 1., 2., 3., 4., 0.],
[ 1., 2., 3., 4., 0.],
[ 1., 2., 3., 4., 0.],
[ 1., 2., 3., 4., 0.],
[ 1., 2., 3., 4., 0.]],
[[ 1., 2., 3., 4., 0.],
[ 1., 2., 3., 4., 0.],
[ 1., 2., 3., 4., 0.],
[ 1., 2., 3., 4., 0.],
[ 1., 2., 3., 4., 0.]]])
my …Run Code Online (Sandbox Code Playgroud) 我正在使用此代码.
let marker = GMSMarker()
marker.position = coordinates
marker.tracksViewChanges = true
marker.icon = UIImage(named:"car")
marker.appearAnimation = kGMSMarkerAnimationNone
marker.map = mapView
Run Code Online (Sandbox Code Playgroud)
位置经理代码
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{
let location = locations.last! as CLLocation
if(checkingLocation == false)
{
let camera = GMSCameraPosition.camera(withLatitude: (location.coordinate.latitude), longitude: (location.coordinate.longitude), zoom: 16.0)
oldLocationCenter = location
marker.position = (locationManager.location?.coordinate)!
self.mapView?.animate(to: camera)
// checkingLocation = true
locationManager.stopUpdatingLocation()
}
else
{
let updateCam = GMSCameraUpdate.setTarget(CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude))
updateMarker(coordinates: location.coordinate, degrees:DegreeBearing(A: oldLocationCenter, B: location) , duration: 10.0) …Run Code Online (Sandbox Code Playgroud) coordinates ×10
google-maps ×2
java ×2
math ×2
python ×2
android ×1
angle ×1
arrays ×1
awt ×1
bioconductor ×1
dataframe ×1
geometry ×1
gmsmapview ×1
graph ×1
graph-layout ×1
ios ×1
ipad ×1
iphone ×1
javascript ×1
maps ×1
matlab ×1
matrix ×1
mouse ×1
numpy ×1
overlapping ×1
r ×1
space ×1
swift3 ×1
swing ×1
touch ×1
vector ×1