Page 1 of 1

### Distances of two different points in x y z coordinates

Posted: Wed Nov 06, 2019 12:47 pm
Hello guys I need to get X Y Z distances between 2 different points. Here is an example of what I want to do: I want to find the distances between the X Y and Z coordinates of two different corners of a room ceiling. I want to do this wirelessly. IR or different sensors or camera with using calibration pattern (I don't know). Distance between points and raspberry (or me) ia maximum 10 meter. How can I get the X Y and Z distances between this 2 points?

### Re: Distances of two different points in x y z coordinates

Posted: Wed Nov 06, 2019 2:03 pm
orgey wrote:
Wed Nov 06, 2019 12:47 pm
Hello guys I need to get X Y Z distances between 2 different points. Here is an example of what I want to do: I want to find the distances between the X Y and Z coordinates of two different corners of a room ceiling. I want to do this wirelessly. IR or different sensors or camera with using calibration pattern (I don't know). Distance between points and raspberry (or me) ia maximum 10 meter. How can I get the X Y and Z distances between this 2 points?

The maths needed to calculate the distance between 2 points in a 3d space with the proportions of a room is surely a simple application of Pythagoras or similar?

The bigger challenge seems to be getting the 2 sets of coordinates as a basis for the calculation.

### Re: Distances of two different points in x y z coordinates

Posted: Wed Nov 06, 2019 2:29 pm
That's what I asked about . I mean calculations ares simple and I don't need the real positions of the points. For example one of the points can be considered as a origin (0,0,0) or anything , it is not important. The important think is x2-x1,y2-y1 and z2-z1. I just need these informations. Btw, thank you for the reply .

### Re: Distances of two different points in x y z coordinates

Posted: Wed Nov 06, 2019 2:51 pm
orgey wrote:
Wed Nov 06, 2019 12:47 pm
Hello guys I need to get X Y Z distances between 2 different points. Here is an example of what I want to do: I want to find the distances between the X Y and Z coordinates of two different corners of a room ceiling. I want to do this wirelessly. IR or different sensors or camera with using calibration pattern (I don't know). Distance between points and raspberry (or me) ia maximum 10 meter. How can I get the X Y and Z distances between this 2 points?
Does it have to be fully automated ?

### Re: Distances of two different points in x y z coordinates

Posted: Wed Nov 06, 2019 2:56 pm
gordon77 wrote:
Wed Nov 06, 2019 2:51 pm
orgey wrote:
Wed Nov 06, 2019 12:47 pm
Hello guys I need to get X Y Z distances between 2 different points. Here is an example of what I want to do: I want to find the distances between the X Y and Z coordinates of two different corners of a room ceiling. I want to do this wirelessly. IR or different sensors or camera with using calibration pattern (I don't know). Distance between points and raspberry (or me) ia maximum 10 meter. How can I get the X Y and Z distances between this 2 points?
Does it have to be fully automated ?
What do you mean? Sorry I don't get it.

### Re: Distances of two different points in x y z coordinates

Posted: Wed Nov 06, 2019 3:02 pm
Does it need to do all the measurements by itself, or can you do some/ or all of it ?

If the latter I was thinking you could use a laser measure. eg https://www.screwfix.com/p/magnusson-im ... urer/1406x

Point it at the first corner. You now know the distance to it from you, and you can measure the angles, both in declination and azimuth. Now repeat for the second and you should now have enough data to do the maths.

### Re: Distances of two different points in x y z coordinates

Posted: Wed Nov 06, 2019 3:08 pm
Not a trivial problem.

A level or higher mathematics would be useful to understand how these techniques work although you may get through treating libraries as black boxes that give you numbers. You would be relying a lot on examples though.

You should start by defining what accuracy you need.

Some techniques:
1. Locate the walls/ ceiling/floor with LIDAR?
2. Laser range finder (triangulation)
3. Ultrasonic distance sensor?
4. Photogrammetry (3D structure from 2D photos)
5. Camera calibration techniques where you compute the camera position relative to a known pattern such as a checkerboard or barcodes
Point a camera to centre a symmetrical marker such a a coloured ball, then turn the camera to centre a second marker.
The camera centre and the two vectors to the targets you have a triangle.
Measuring the diameter of the ball targets gives you a measure of distance on each of two sides of the triangle so you can calculate the other side which is the distance between the centre of the balls.

Shaper Origin uses some variant of 5. to find precise location of a router tool relative to known patterns on tapes stuck onto the workpiece. Watch it in action.
https://www.shapertools.com/en-us/store

OpenCV has library functions to camera calibration and photogrammetry

https://becominghuman.ai/stereo-3d-reco ... 13907d1ab5

https://docs.opencv.org/2.4/modules/cal ... ction.html

### Re: Distances of two different points in x y z coordinates

Posted: Wed Nov 06, 2019 5:15 pm
PiGraham wrote:
Wed Nov 06, 2019 3:08 pm
Not a trivial problem.
It shouldn't be too hard - Assuming it's the distance between the two corners which is wanted.

Park a laser distance sensor on a tripod, adjust its tilt until the laser beam can be swung to hit the two corners. Measure the two distances and use the angle swung to calculate the distance between the two corners.

If it's more than that the OP might have to explain exactly what they want and what "X Y Z distances between 2 different points" means because it seems impossible to calculate having only three points of reference.

### Re: Distances of two different points in x y z coordinates

Posted: Wed Nov 06, 2019 5:50 pm
hippy wrote:
Wed Nov 06, 2019 5:15 pm

Park a laser distance sensor on a tripod, adjust its tilt until the laser beam can be swung to hit the two corners. Measure the two distances and use the angle swung to calculate the distance between the two corners.
I mentioned two types of laser distance sensor.
True it would be a lot simpler to target the corners by eye and read the angles from transducers.

I don't know how well a laser triangulation sensor will read in a corner. Maybe put an irregular tetrahedron (diagonally sectioned cube) in the corner to provide a flat surface to read off.

Alternatively do the ranging to the walls to get x,y,z distances and calculate from those. Any three points on a wall define the plane of the wall. The corner is the intersection of three planes.

### Re: Distances of two different points in x y z coordinates

Posted: Wed Nov 06, 2019 5:54 pm
Actually, its probably a reasonable assumption that the walls are vertical so a horizontal sweep of a distance sensor of any type could give you the walls and a range straight up could give the ceiling which gets you the corners.
It all depends what accuracy is needed because walls aren't perfectly vertical or flat and ceilings and floors aren't perfectly level and flat either.

### Re: Distances of two different points in x y z coordinates

Posted: Thu Nov 07, 2019 7:47 am
If you have an iphone, check out the Measure App. It works by using the camera. Essentially, you move/scan the iphone in front of what you want to measure, and based on how the image changes on the screen, the algorithm is capable to 'calculate' some dimensions. Pretty slick, but a lot of image processing and calculations. Yes, you can try something like that ... let us know once you figure that out The method the iPhone uses is based on photogrammetry ... too difficult to do by yourself. Your best bet is to find some online/free library.

### Re: Distances of two different points in x y z coordinates

Posted: Thu Nov 07, 2019 11:09 am
I tried the measurements of my room using the distance to the points and the 2 angles as I described above and it appeared to work !!.

Here's the code and a picture which I hope explains it. It doesn't use walls or floor as reference.

The bad news is the laser wouldn't measure the distance, presumably due to the angle. so I had to use a tape.

I measured the angles by mounting the laser on a camera tripod which shows the angles.

Code: Select all

``````#!/usr/bin/env python3
import math

#============================================================

# ENTER DATA HERE...

a = 2.70       # distance to first point
e = 25.00      # elevation angle (in degs) to first point
h = 5.00       # longtitude angle (in degs) to first point
b = 2.65       # distance to second point
f = 28.00      # elevation angle (in degs) to second point
j = -45.00     # longtitude angle (in degs) to second point

#============================================================

e = e * 0.01745329252 # convert to radians
h = h * 0.01745329252 # convert to radians

y1 = math.sin(e) * a

c = y1/math.tan(e)

x1 = c * math.sin(h)
z1 = x1/math.tan(h)

f = f * 0.01745329252 # convert to radians
j = j * 0.01745329252 # convert to radians

y2 = math.sin(f) * b

d = y2/math.tan(f)

x2 = d * math.sin(j)
z2 = x2/math.tan(j)

print ("X1 = ",x1," Y1 = ",y1," Z1 = ",z1)
print ("X2 = ",x2," Y2 = ",y2," Z2 = ",z2)
print ("X1-X2 = ",x1-x2," Y1-Y2 = ",y1-y2," Z1-Z2 = ",z1-z2)

t = math.sqrt((x1-x2)*(x1-x2) + (z1-z2)*(z1-z2))
u = math.sqrt((t*t) + (y1-y2)*(y1-y2))
print ("DISTANCE BETWEEN POINTS = ", u)

``````

### Re: Distances of two different points in x y z coordinates

Posted: Fri Nov 08, 2019 6:10 am
Guys, thank you all for your replies. I am an electrial engineer, I am really good at math . What I want is get the x y and z coordinates of 2 different points. Or I can assume that one point as a referance and get the x y z coordinates of the other point (x2-x1,y2-y1 and z2-z1 x1=y1=z1=0). I can put measurement devices to the points, but I can't take them back, so the devices or items must be cheap (calibrated pattern or cheap sensors). The main device that I will take the measurement may be the phone or the raspberry pi or a different device. I have no restrictions on that device. I hope I was able to explain my wishes correctly. Thank you all ### Re: Distances of two different points in x y z coordinates

Posted: Fri Nov 08, 2019 7:58 am
You still haven't indicated what sort of accuracy you need for this measurement. That's critical.
The other key parameter is what distances you need to measure.

You can measure anything with triangulation, so long as you have at least one known distance.

### Re: Distances of two different points in x y z coordinates

Posted: Fri Nov 08, 2019 12:05 pm
orgey wrote:
Fri Nov 08, 2019 6:10 am
The main device that I will take the measurement may be the phone or the raspberry pi or a different device. I have no restrictions on that device.
With no restrictions, use LIDAR or something similar and scan the entire room. That will allow the creation of a virtual model of the room from which anything can be determined with reference to anything else.

Maybe investigate what archaeologists use for 3D scanning.

### Re: Distances of two different points in x y z coordinates

Posted: Fri Nov 08, 2019 1:53 pm
I don't think ". I have no restrictions on that device." means "money no object".

Still, this is cool if can afford it. Measure whatever you want.

Or

### Re: Distances of two different points in x y z coordinates

Posted: Fri Nov 08, 2019 5:23 pm
If it has to be cheap you could try 2 cameras, probably usb so 2 will work on a pi, and determine the distances to the points, from the difference between the images after you have calibrated. You could then use my earlier method with measured angles.

### Re: Distances of two different points in x y z coordinates

Posted: Sat Nov 09, 2019 10:35 am
gordon77 wrote:
Fri Nov 08, 2019 5:23 pm
If it has to be cheap you could try 2 cameras, probably usb so 2 will work on a pi, and determine the distances to the points, from the difference between the images after you have calibrated. You could then use my earlier method with measured angles.
Good point. If two cameras are rigidly mounted and calibrated you can get accurate real world angles of points in the images. You can measure sizes of known targets and calculate distance from size. Place a ball in the corners you ant to measure and find the centre and diameter to get vector and range.

If you can move the cameras by accurate angles you can calibrate between the views.
You may be able to use Hough transforms to find the straight line joins between walls, ceiling and floor and from those lines you could calculate the intersection points that give the corners of a room.

OpenCV has the functions for all that.

### Re: Distances of two different points in x y z coordinates

Posted: Sat Nov 09, 2019 12:10 pm
I was thinking more of a rangefinder type setup to measure the distance. See image below which has the cameras set to coincide at 1m and you could measure the distance by the displacement beyond that. The tripod handle is at 1m and the cupboards behind at 2m.

Measuring the angles from the pictures could work as well.

### Re: Distances of two different points in x y z coordinates

Posted: Sat Nov 09, 2019 4:13 pm
Certainly that sort of 3D from stereo can be done.
As with any triangulation method the accuracy reduces as the separation reduces and the angle becomes very acute.
I think there's a tradeoff because wider separation improves the angle but also changes the view which can make feature matching harder.

### Re: Distances of two different points in x y z coordinates

Posted: Tue Nov 12, 2019 5:51 am
PiGraham wrote:
Fri Nov 08, 2019 1:53 pm
I don't think ". I have no restrictions on that device." means "money no object".

Still, this is cool if can afford it. Measure whatever you want.

Or

I need to calculate distance between 2 spesific objects (Actually 2 different cables end point distance in 3d coordinate systems). Can I do this with Hottscan or can I just measure the room dimensions?

### Re: Distances of two different points in x y z coordinates

Posted: Tue Nov 12, 2019 8:42 am
Can you give us some indication of dimensions of the room, and distance to and between points ?

### Re: Distances of two different points in x y z coordinates

Posted: Tue Nov 12, 2019 9:35 am
orgey wrote:
Tue Nov 12, 2019 5:51 am

I need to calculate distance between 2 spesific objects (Actually 2 different cables end point distance in 3d coordinate systems).

I thought you had agreed with me when I wrote "The maths needed to calculate the distance between 2 points in a 3d space with the proportions of a room is surely a simple application of Pythagoras or similar?"

### Re: Distances of two different points in x y z coordinates

Posted: Tue Nov 12, 2019 9:41 am
orgey wrote:
Tue Nov 12, 2019 5:51 am
PiGraham wrote:
Fri Nov 08, 2019 1:53 pm
I don't think ". I have no restrictions on that device." means "money no object".

Still, this is cool if can afford it. Measure whatever you want.