Calculating a distance between random points.
Hi everyone,
so my situation is like this :
1) I have created a graph containing random points (3 different series). And the graph have three buttons .The first button will plot 30 random points on the chart. the second and third button will plot random point with different colour.
What I am trying to do now is I need to choose one random point from the 30 points, and calculate the distance from the chosen point to the qrand or qinit..
How can I do that? I really have no idea. Help!
public void ForBtn1()
Random qrand = new Random();
int[,] points = new int[100, 2];
int qinitx, qinity;
for (int i = 0; i < 30; i++)
int pointx = qrand.Next(0, 100);
int pointy = qrand.Next(0, 100);
points[i, 0] = pointx;
points[i, 1] = pointy;
qinitx = points[0,0];
qinity = points[0, 1];
chart1.Series["Initial Point"].Points.AddXY(pointx, pointy);
chart1.Series["Initial Location"].Points.AddXY(qinitx,qinity);
//To initialize random points and initial point
private void button1_Click(object sender, EventArgs e)
ForBtn1();
private void chart1_Click(object sender, EventArgs e)
//To initialize rand_config
private void button2_Click(object sender, EventArgs e)
Random qrand = new Random();
int[,] points = new int[100, 2];
int qrandx, qrandy;
qrandx = qrand.Next(0,100);
qrandy = qrand.Next(0,100);
chart1.Series["Random Configuration"].Points.AddXY(qrandx, qrandy);
private void button3_Click(object sender, EventArgs e)
i cannot attach the photo here .. i dont know why. but here's the photo . check this link.. i uploaded it to fb..
https://fbcdn-sphotos-e-a.akamaihd.net/hphotos-ak-xpa1/v/t1.0-9/11054299_811876005567689_3794441462666954824_n.jpg?oh=7c9576e4f1f9b2a7e2ac9cf744383051&oe=55AC5BD5&__gda__=1438193773_becbb041c6c51cfc4db4b38c2d18e7a2
Similar Messages
-
Customizing distance between data Points on x-Axis
Hi,
I want to draw a LineChart.
I have these Timestamps [84, 1000, 34000, 34699, 439999] who
are represanting the x-Value of DataPoints along the X-Axis.
Unfortunately the distance between 2 datapoints along the
x-Axis is always the same, that means that between the points with
x-values 84 and 1000 is the same distance along the axis as between
the points with x-values 34699 and 439999.
But the distance between points with x-values of 34699 and
439999 should be much greater than between 84 and 1000.
How can I customize the distance between data Points on a
LineChart to solve my Problem?
I really dont know right now!
Greeting,
Z."zidaninho" <[email protected]> wrote in
message
news:gls479$nkt$[email protected]..
> Hi,
>
> I want to draw a LineChart.
> I have these Timestamps [84, 1000, 34000, 34699, 439999]
who are
> represanting
> the x-Value of DataPoints along the X-Axis.
>
> Unfortunately the distance between 2 datapoints along
the x-Axis is always
> the
> same, that means that between the points with x-values
84 and 1000 is the
> same
> distance along the axis as between the points with
x-values 34699 and
> 439999.
> But the distance between points with x-values of 34699
and 439999 should
> be
> much greater than between 84 and 1000.
>
> How can I customize the distance between data Points on
a LineChart to
> solve
> my Problem?
>
> I really dont know right now!
What happens if you convert the time stamps to Dates and use
a DateAxis? -
Hi all, I am trying to find the distance between all points in an array. I was able to get the all possible combinations but i am not getting the expected ouput.
For eg, if i have four points, total number combinations are going to be 6 and i want to find distance in all six combinations.
Please help me where i did mistake. Please find the attached vi.
Thanks
uday,
Please Mark the solution as accepted if your problem is solved and help author by clicking on kudoes
Certified LabVIEW Associate Developer (CLAD) Using LV13
Solved!
Go to Solution.
Attachments:
Find distance between all points.vi 17 KBTry something like this.
Since I don't have the IMAQ function, I am using complex data for each point, but it would be trivial to adapt it to your data structures instead.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
Find distance between all points.png 33 KB
Find distance between all pointsMODCA.vi 10 KB
Find distance between all pointsFP.png 21 KB -
How to measure distance between two points uisng uiaccelerometer
Hello all,
I am trying to measure distance between two points.So for that i am used uiaccelerometer but its give only rotation changes. I am moving my whole device from one point to another point so for that all x,y & z changes remain same. So how can get the device movement for that?
Thank you..UIAccelerometer does not give rotation changes, it senses acceleration in each of the 3 axis in g-force units. Moving in a plane from one point to another and stopping will result in a net g-force in that axis of zero. To get distance one has to measure the initial acceleration and then the time before a deceleration is detected. It gets really complicated in real life since the start and stop are not instantaneous.
-
Find driving distance between two points without using API by use of Lat & Long?
Using Google geocode API : http://maps.googleapis.com/maps/api/geocode/xml?address=thane&sensor=true
We performed get distance between search criteria entered by user and all related clubs by lat & long stored at db.
2. Two different points such as
(origin: Lat1 & Long1) and (destination: Lat2 & Long2)
We tried for to get distance between these two points,
(Lat2 & Long2) to (Lat1 & Long1)
But distance which we get by calculation is simple straight line distance
Origin Destination
(Lat1 & Long1) (Lat2 & Long2)
3. This is not driving distance as google shows in exact Km
4. For that Google provide another API (distancematrix API)
http://maps.googleapis.com/maps/api/distancematrix/xml?origins=Thane&sensor=true&destinations=khopat&mode=driving&language=en%20-%20EN
5. But there is limit for DistanceMatrix-Service without ClientID and client key
100 elements per query.
100 elements per 10 seconds.
2 500 elements per 24 hour period.
But as element request exceeds it shows : OVER_QUERY_LIMIT error
6. In case of Client ID and Client key
In Distance Matrix 100 000 elements per 24 hour period,a maximum of 625 elements per query and a maximum of 1 000 elements per 10 seconds.
As per this one there is option to get purchase these API but basic question is remain same for us if we are requesting single origin and multiple destination then how element calculation done by google?
But in document google says :
Elements
The information about each origin-destination pairing is returned in an element entry. An element contains the following fields:
Status: See Status Codes for a list of possible status codes.
Duration: The duration of this route, expressed in seconds (the value field) and as text. The textual representation is localized according to
the query's language parameter.
Distance: The total distance of this route, expressed in meters (value) and as text. The textual value uses the unit system specified with the
unit parameter of the original request, or the origin's region.Any information that you see in a google map webpage can be retrieved using the API. The best way of finding the tags on the webpage is to manually perform the query using an IE webpage. Then capture the source and save to a file so you
can use a text editor to look at results. I often on a webpage use the menu : View - Source and then copy the source to a text file.
jdweng -
Distance between two points with degrees and minutes
I would like to store several points in the database given degrees and minutes as position. In this example I have point 1 that is E 150, 0/S 30, 0 and points 2 that is E 150, 0/S 30.1. For example if I enter 2 km as distance from position of point 1 I would like the search to return all points witin 2 km.(should return points 2 that is very near)
If I run the query
SELECT c.name
FROM cola_markets_cs c
WHERE
SDO_WITHIN_DISTANCE(c.shape,
SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(150.0, 30.1, NULL), NULL, NULL),
'distance=10000 unit=KM')
= 'TRUE';
I get result both position 1 and 2, but if I decrease to distance=1000 no rows is returned.
Can you see what I am doing wrong here?
Can I also combine SDO_WITHIN_DISTANCE with SDO_NN_DISTANCE so I can ask for all points 10 km in distance from the reference point and I can also see the actual distance for each point?
Thank you
I have tested with the following code. Do I save the position wrong..?
CREATE TABLE cola_markets_cs (
mkt_id NUMBER PRIMARY KEY,
name VARCHAR2(32),
shape MDSYS.SDO_GEOMETRY);
INSERT INTO cola_markets_cs VALUES (
1,
'Point 1',
MDSYS.SDO_GEOMETRY(
2001,
8307,
MDSYS.SDO_POINT_TYPE(150.0, 30.0, NULL),
NULL,
NULL
INSERT INTO cola_markets_cs VALUES (
2,
'Point 2',
MDSYS.SDO_GEOMETRY(
2001,
8307,
MDSYS.SDO_POINT_TYPE(150.0, 30.1, NULL),
NULL,
NULL
-- UPDATE METADATA VIEW --
-- Update the USER_SDO_GEOM_METADATA view. This is required
-- before the Spatial index can be created. Do this only once for each
-- layer (i.e., table-column combination; here: cola_markets_cs and shape).
INSERT INTO USER_SDO_GEOM_METADATA
VALUES (
'cola_markets_cs',
'shape',
MDSYS.SDO_DIM_ARRAY(
MDSYS.SDO_DIM_ELEMENT('Longitude', -180, 180, 10), -- 10 meters tolerance
MDSYS.SDO_DIM_ELEMENT('Latitude', -90, 90, 10) -- 10 meters tolerance
8307 -- SRID for 'Longitude / Latitude (WGS 84)' coordinate system
-- CREATE THE SPATIAL INDEX --
-- Must be R-tree; quadtree not supported for geodetic data.
CREATE INDEX cola_spatial_idx_cs
ON cola_markets_cs(shape)
INDEXTYPE IS MDSYS.SPATIAL_INDEX;
--This search only return if distance is 10 000 km...
SELECT c.name
FROM cola_markets_cs c
WHERE
SDO_WITHIN_DISTANCE(c.shape,
SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(150.0, 30.1, NULL), NULL, NULL),
'distance=10000 unit=KM')
= 'TRUE';
--According to this search the distance to point 1 is 3331198,72256398,
--this should be zero..
SELECT
c.mkt_id, c.name, SDO_NN_DISTANCE(1) dist
FROM cola_markets_cs c
WHERE SDO_NN(c.shape,
sdo_geometry(2001, 8307,sdo_point_type(150.0, 30.1, NULL), NULL, NULL),
'sdo_num_res=2', 1) = 'TRUE' ORDER BY distHi,
What version of Oracle are you using? I got this using your example:
SELECT
c.mkt_id, c.name, SDO_NN_DISTANCE(1) dist
FROM cola_markets_cs c
WHERE SDO_NN(c.shape,
sdo_geometry(2001, 8307,sdo_point_type(150.0, 30.1, NULL), NULL, NULL), 'sdo_num_res=2', 1) = 'TRUE'
ORDER BY dist ;
MKT_ID NAME DIST
2 Point 2 0
1 Point 1 11085.3285
This is 10.1.0.4
Also:
Can I also combine SDO_WITHIN_DISTANCE with SDO_NN_DISTANCE so I can ask for all points 10 km in distance from the reference point and I can also see the actual distance for each point?
No, but you can add a distance calculation:
SELECT
c.mkt_id, c.name, SDO_GEOM.SDO_DISTANCE(c.shape,sdo_geometry(2001, 8307,sdo_point_type(150.0, 30.1, NULL), NULL, NULL),1) dist
FROM cola_markets_cs c
WHERE SDO_WITHIN_DISTANCE(c.shape,
sdo_geometry(2001, 8307,sdo_point_type(150.0, 30.1, NULL), NULL, NULL), 'distance=10 unit=km') = 'TRUE'
ORDER BY dist ; -
Excel formula to calculate the distance between multiple points using lat/lon coordinates
I'm currently drawing up a mock database schema with two tables: Booking and Waypoint.
Booking stores the taxi booking information.
Waypoint stores the pickup and drop off points during the journey, along with the lat lon position. Each sequence is a stop in the journey.
How would I calculate the distance between the different stops in each journey (using the lat/lon data) in Excel?
Is there a way to programmatically define this in Excel, i.e. so that a formula can be placed into the mileagecolumn
(Booking table),
lookup the matching sequence (via bookingId)
for that journey in the Waypointtable
and return a result?
Example 1:
A journey with 2 stops:
1 1 1 MK4 4FL, 2, Levens Hall Drive, Westcroft, Milton Keynes 52.002529 -0.797623
2 1 2 MK2 2RD, 55, Westfield Road, Bletchley, Milton Keynes 51.992571 -0.72753
4.1 miles according to Google, entry made in mileage column
in Booking table
where id
= 1
Example 2:
A journey with 3 stops:
6 3 1 MK7 7DT, 2, Spearmint Close, Walnut Tree, Milton Keynes 52.017486 -0.690113
7 3 2 MK18 1JL, H S B C, Market Hill, Buckingham 52.000674 -0.987062
8 3 1 MK17 0FE, 1, Maids Close, Mursley, Milton Keynes 52.040622 -0.759417
27.7 miles according to Google, entry made in mileage column
in Booking table
where id
= 3
I understand that 100% accuracy is not possible, so it will not be an issue.http://www.cpearson.com/excel/LatLong.aspx
and
http://www.contextures.com/excellatitudelongitude.html -
Command for calculating the difference between channel points
Hello guys,
Please tell me if there is a command (or a way) to calculate the diference between channel points, and when there is a diference between points greater then a certain value, to give you where are those points.
I record some CSV data, a force during time and travel, and I want to put on a graph the exact value when I have a decrease of force greater then 0,1N.
Thank you again for your time.
Solved!
Go to Solution.Hello again,
I find out about the ChnDeltaCalc command, and I combine it with ChnFind and ChD commands and everything is OK.
Have a nice day. -
Calculating the Distance between particles
I'm building a VI to analysis CCD's for defects.
One of the defects I'm looking for is clusters of contiguous point defects.
I've found the image processing particle detection routines which can be used to find these clusters, however to pass there must no cluster within 3 pixels of any other cluster.
Can anyone think of a way of measuring the ditance between clusters, since the particle detection vi gives the total bounds which could, due to irregular clusters, give the impression of closeness but actual pass my specification.Robert,
The simplest way I can come up with is to use Binary Morphology. If you use Dilate, it will make all your particles grow. By selecting the proper parameters, you should be able to get all your particles to increase their size by half the minimum spacing. If the spacing between two particles was less than the minimum, they should run together and become a single particle. Use particle detection and see if the total number of particles has decreased, and that will tell you if two particles ran together.
If necessary, you could design more elaborate detection algorithms at the end. You could subtract the original image from the dilated image, which would leave holes where the original particles were. Using particle detection, you could count
the number of holes in each particle. I think the result would be the same, though.
You would have to make sure you remove any particles that aren't clusters before doing the processing. Two tiny specs could run together and change your count, when they are just noise.
Bruce
Bruce Ammons
Ammons Engineering -
I have an application where I am collecting GPS data and all is well, had no problem writing the drivers for gps communication but now I need to calculate displacement between my long and lat readings. Is there a labview function developed to do this or do I need to figure out the calculations and code it myself. I am trying to not reinvent the wheel.
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGAThere is a vi for the Garmin GPS, here.
Here is an application in the Developper's Zone
You may want to check out this thread
Message Edited by JoeLabView on 06-13-2007 08:48 AM -
Minimum distance between access points
Is it possible to locate 2 ap's (1200s) so close that they desense each other? I'm having some performance issues in an area where the 1200s are pretty close to each other.
Thanks for any help on this.
MarkHi Mark,
It is possible to locate AP's so close that they cause each other problems. Here is a link to a good document for the 1200 AP.
http://www.cisco.com/en/US/products/hw/wireless/ps430/products_tech_note09186a00805190f1.shtml#topic4
Here is an excerpt from the actual doc:
Position the APs Optimally
"The placement of the APs at the correct places is an important factor that accounts in the extension of the coverage area of the AP. Too many APs in the same vicinity can create radio congestion and interference, and reduce the throughput.
A careful site survey can determine the best placement of APs for maximum radio coverage and throughput."
Hope this helps!
Rob
Please remember to rate helpful posts........... -
Calculating co-ordinate distances between specific atoms
Hi,
Below is some code to calculate distances between all pairs of atoms. However, i need to make it slightly more specific by only calculating the distance between certain pairs of atoms
input
ATOM 5 CA PHE 1 113.142 75.993 130.862
ATOM 119 CA LEU 7 113.101 72.808 140.110
ATOM 138 CA ASP 8 109.508 74.207 140.047
ATOM 150 CA LYS 9 108.132 70.857 141.312
ATOM 172 CA LEU 10 110.758 70.962 144.119
e.g distance between all pairs for atoms 5, 119, 150 and 172 (say), last three columns are x,y and z co-ordinates
code it self
import java.util.*;
import java.io.*;
public class Distance {
public static void main(String[] args) {
System.out.println("***Campbells PDB Distance Calculator***" + "\n");
new Distance();
System.out.println("\nResults printed to file DistanceCalculations" + "\n");
System.out.println("\nDue to nature of code, if rerun results will be appended to the end of previous run.");
public Distance() {
Vector atomArray = new Vector();
String line;
try{
System.out.println("Enter PDB file:" + "\n");
BufferedReader inputReader =new BufferedReader (new InputStreamReader(System.in));
String fileName = inputReader.readLine();
if ( fileName !=null) {
BufferedReader inputDistance = new BufferedReader (new FileReader (fileName));
while (( line = inputDistance.readLine()) !=null && !line.equals(""))
Atom atom = new Atom(line);
atomArray.addElement(atom);
for (int j=0; j<atomArray.size(); j++) {
for (int k=j+1; k<atomArray.size(); k++) {
Atom a = (Atom) atomArray.elementAt(j);
Atom b = (Atom) atomArray.elementAt(k);
Atom.printDistance (a,b);
} //if
} //try
catch (IOException e) {
System.out.println("Input file problem");
} catch (Exception ex) {
System.out.println (ex);
class Atom {
public double x, y, z;
public String name;
public Atom(String s) throws IllegalArgumentException {
try {
StringTokenizer t = new StringTokenizer (s, " ");
t.nextToken();
this.name = t.nextToken();
for (int j=0; j<3; j++) t.nextToken();
this.x = new Double(t.nextToken()).doubleValue();
this.y = new Double(t.nextToken()).doubleValue();
this.z = new Double(t.nextToken()).doubleValue();
catch (Exception ex) {
throw new IllegalArgumentException ("Problem!!!! :-(");
public String toString() {
return "atom : " + name + "(x=" + x + " y=" + y + " z=" + z + ")";
public double distanceFrom (Atom other) {
return calculateDistance (x, y, z, other.x, other.y, other.z);
public static double calculateDistance (double x1, double y1, double z1, double x2, double y2, double z2) {
return Math.sqrt(Math.sqrt(Math.pow(Math.abs(x1-x2),2)+Math.pow(Math.abs(y1-y2),2))+Math.pow(Math.abs(z1-z2),2));
public static void printDistance (Atom a, Atom b) {
try{
FileWriter fw = new FileWriter("DistanceCalculations", true);
PrintWriter pw = new PrintWriter (fw, true);
if
(a.distanceFrom(b) <9){
pw.println("Distance between " + a.toString() + " and " + b.toString() + " is " + a.distanceFrom(b));
pw.flush();
pw.close();
} // if??
} //try loop
catch(IOException e) {
System.out.println("System error");
}ok, essentially
want to calculate distance between to ranges. Say
range 1 is the first three, range 2 the rest. THen
calculate distance between all possible pairs between
these two rangesYes - and no doubt that any number of people here could write it for you. But that's not what the forum is about. So what, exactly, is preventing you from doing it?
Sylvia. -
Getting the length between two points
Hi All,
I am trying to get the distance between two points and came across the SDO_LENGTH function in the manual - however there is no example on how to use it.
I was expecting the following statement to return me the value 9 but instead I am getting errors along the lines of SDO_GEOM.SDO_LENGTH must be declared etc.
=============================================
SDO_GEOM.SD0_LENGTH(
MDSYS.SDO_GEOMETRY(2
,NULL
,NULL
,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1)
,MDSYS.SDO_ORDINATE_ARRAY(1,1,10,10))
,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,0.0001)
,MDSYS.SDO_DIM_ELEMENT('Y',-90,90,0.0001))
============================================
what am I missing
any help appreciated
Brent GloverI think I have found my answer
============================================
DECLARE
v_length NUMBER;
BEGIN
v_length := SDO_GEOM.SDO_LENGTH(
MDSYS.SDO_GEOMETRY(2
,NULL
,NULL
,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1)
,MDSYS.SDO_ORDINATE_ARRAY(1,1,10,10))
,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,0.0001)
,MDSYS.SDO_DIM_ELEMENT('Y',-90,90,0.0001))
DBMS_OUTPUT.put_line(v_length);
END;
============================================= -
Calculating distance between Lat Long points
I'm wondering if anyone out there has done this before in LabVIEW. Does anyone have a model of the "Great Circle" calculation? I have a file of lat/long points that I need to calculate the distance between. Any help??
V/r,
ChrisI haven't done it in LV, but if you go to Wikipedia and search for Great Circle Distance you'll find the formual and an example.
-
Hi,
my macbook screen goes black at random points when I am using it. I know it is still running as music continues to play and I can vaguely make out the content of what is on the screen. Sometimes the screen will flicker between black and normal. Can I fix this?Emily..
Could be the graphics card, run the Apple Hardware Test
If the hardware test doesn't reveal any problems, use Lion Recovery.
Maybe you are looking for
-
In SAP-XI stop generating of xml files
Hi, In sap-xi i created a simple file to file scenario. After completion of end to end scenario the xml files are keep on generating. I have selected delete option in CommunicationChannel. The xml file from source folder is deleted. Still the taget
-
How to draw a border around a TreeNode control?
I have a TreeView that contains levels of TreeNodes. How do I draw borders around the text of the TreeNode? The TreeNode class does not accept a border style property. Assigning the property to TreeView only draws an outside window around the entire
-
Dual G5 hangs while booting from internal hard-disk
Hi, When I switched my Dual G5 (2x2.5GHz around 15 months old, 1.5GB ram, 160GB hard disk, OS 10.4.6) on yesterday, it wouldn't boot from the internal hard disk. The spinning "wheel" (under the Apple logo) didn't show up and after a couple (5? 10?) o
-
Appearance of secured portlets in the page
I have portlets that are secured by user_id all published in one page. When a user signs on, they see their portlets and blank lines for portlets that they do not have access to. Is their any way to avoid these balnk lines. Thanks Valli
-
HT2953 Why will my song not drop in the recorder
I made a Title and description for my song list and when I drag and drop the song to the recorder, it has a red circle and won't drop it.