I really lost in the Euclidean distance calculation . For this, I found the functions dist2 {SpatialTools} or rdist {fields}, but they do not work properly.
I believe that one point has two coordinates in the map system, therefore [x, y]. To measure the distance between two points (determined by the line), I need 4 coordinates for 2 points, so point A: [x1, y1] point B: [x2, y2]
Point coordinates:

A[0,1] B[0,0] C[1,1] D[1,1]
I have two matrices: x1 (there are A and C defined by rows) and x2 (contain B and D). It is written in a matrix:
library("SpatialTools") x1<-matrix(c(0,1,1,1), nrow = 2, ncol=2, byrow=TRUE) x2<-matrix(c(0,0,1,1), nrow = 2, ncol=2, byrow=TRUE)
so i get
> x1 [,1] [,2] [1,] 0 1 #(as xy coordinates of A point) [2,] 1 1 #(same for C point) > x2 [,1] [,2] [1,] 0 0 #(same for B point) [2,] 1 1 #(same for D point)
To calculate the Euclidean distance between
A <-> B # same as x1[1,] <-> x2[1,] C <-> D # same as x1[2,] <-> x2[2,]
I suppose to get an EuclidDist :
> x1 x2 EuclidDist [,1] [,2] [,1] [,2] [1,] 0 1 #A [1,] 0 0 #B 1 [2,] 1 1 #B [2,] 1 1 #D 0
I would just like to get the distance vector between two points identified by the coordinates [x, y] , however, using dist2 , I get the matrix:
> dist2(x1,x2) [,1] [,2] [1,] 1.000000 1 [2,] 1.414214 0
My question is, which numbers describe the real Euclidean distance between AB and CD from this matrix? I do not understand something? Thanks so much for every tip or any explanation.