distance

Create vector from distance and vector

旧街凉风 提交于 2019-12-23 06:06:27
问题 How can I create vector from another vector and a distance? For example, with a vector3d(1,1,2) and distance 12, create another vector that has the same direction but is longer by 12 units. 回答1: You want to find the unit vector in the direction you want; in XNA this is given by Vector3.Normalize . Then you can scalar multiply that unit vector (which has, by definition, length = 1) by the final distance. Ex.: var originalVector = new Vector3(1, 1, 2); var finalLength = originalVector.Length +

Calculating distance between 400 cities and optimizing MySQL for it?

╄→尐↘猪︶ㄣ 提交于 2019-12-23 05:15:21
问题 I've got a database of around 400 cities. User selects a city in which he lives, and enters the distance which he is willing to travel (for example, 40kilometers). The city_id is stored into search table, with some other irrelevant information. When user submits the form, he's redirected to results page, on which all results from search table are shown, that meet the criteria, but I want to order them by the distance between city form user's city and the result city, and order the results by

How do I set distance to annotation in tableview?

柔情痞子 提交于 2019-12-23 04:47:20
问题 I have an app that fetches web data and stores it in CD-db. So far, FirstViewController (MKMapView) fetches CD-db into NSMutableArray and uses its values to plot locations by getting the array of custom objects from the db. I cycle thru a for loop while creating the annotation (pin). Each pin gets its distance property set from a calculation I use for the distance from userLocation to each pin. This app runs in a tabbarcontroller and the other tab is a tableview listing of these locations. I

How to create a Large Distance Matrix?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 03:57:13
问题 How to allocate a huge distance matrix in an appropriate way to avoid " allocation is unable " error. Imagine you have a 100.000 points randomly spreaded over some space. How can one cleverly create a matrix or "dist"-object, which represents the the half of DistMatrix. Maybe it should be another object, which will be able efficiently allocate the large number of distances. You can get the polygonial object from the following link: https://www.dropbox.com/sh/65c3rke0gi4d8pb/LAKJWhwm-l # Load

How to create a Large Distance Matrix?

半世苍凉 提交于 2019-12-23 03:57:06
问题 How to allocate a huge distance matrix in an appropriate way to avoid " allocation is unable " error. Imagine you have a 100.000 points randomly spreaded over some space. How can one cleverly create a matrix or "dist"-object, which represents the the half of DistMatrix. Maybe it should be another object, which will be able efficiently allocate the large number of distances. You can get the polygonial object from the following link: https://www.dropbox.com/sh/65c3rke0gi4d8pb/LAKJWhwm-l # Load

Boids in python; calculating distance between two boids

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 03:14:14
问题 I'm trying to program the behaviour of birds in flight with boids in Python. I haven't found much yet but currently i'm stuck on the function defining the distance between two boids. It has to be calculated with the formula (a,b) = sqrt( (a_x - b_x)^2 + (a_y - b_y)^2) ) where a and b are the two vectors between which i have to calcualte the distance, a_x and b_x are the x-components of the vectors and a_y and b_y are the y-components. I get an error about the indices in the formula. I've

Boids in python; calculating distance between two boids

青春壹個敷衍的年華 提交于 2019-12-23 03:14:00
问题 I'm trying to program the behaviour of birds in flight with boids in Python. I haven't found much yet but currently i'm stuck on the function defining the distance between two boids. It has to be calculated with the formula (a,b) = sqrt( (a_x - b_x)^2 + (a_y - b_y)^2) ) where a and b are the two vectors between which i have to calcualte the distance, a_x and b_x are the x-components of the vectors and a_y and b_y are the y-components. I get an error about the indices in the formula. I've

Calculate the minimum distance between two given circular arcs

时光怂恿深爱的人放手 提交于 2019-12-23 02:46:33
问题 I'm trying to find a way to calculate the minimum distance between two given circular arcs. I found a solution in this link. It seems true but I don't know why that is correct!Can anyone prove it right? 回答1: The solution you refer to works because it is based on the properties of arks: An arc is a part of the circle Minimum distance is always reached either at the endpoints or at the perpendicular because it minimizes the distance (objective function). Think of two circles - minimal is always

MATLAB function to calculate distance between two coordinates (latitude and longitude)

半世苍凉 提交于 2019-12-23 02:25:29
问题 How can I calculate distance between two world map coordinates (latitude and longitude) using MATLAB R2015a (in meters)? 回答1: If you don't have access to the MATLAB Mapping toolbox then a simple approximation is to use the Haversine formula. Here is an excerpt from the link: The haversine formula is an equation important in navigation, giving great-circle distances between two points on a sphere from their longitudes and latitudes. It is a special case of a more general formula in spherical

How to use distHaversine function?

倾然丶 夕夏残阳落幕 提交于 2019-12-22 12:39:42
问题 I am trying to use the distHavrsine function in R, inside a loop to calculate the distance between some latitude and longitude coordinates for a several hundred rows. In my loop I have this code: if ((distHaversine(c(file[i,"long"], file[i,"lat"]), c(file[j,"long"], file[j,"lat"]))) < 50 ) after which if the distance is less than 50 meters i want it to record those rows, and where the latitude and longitude coordinates it is referencing look like: 0.492399367 30.42530045 and 0.496899361 30