Trigonometry for 3D Scanning

80 Views Asked by At

I have the following structure: a turntable and a moving distance sensor (VL53L0X, which gives me a distance in milimetres) and I need to create a point cloud. Everything, but this calculation for X, Y and Z points, on the software is working.

The Structure: Structure

What I've tried:

// This reads, in millimeters, the distance
float z = sensor.readRangeContinuousMillimeters();
// 512 steps are needed on the step motor for a full turn on the table (512 * 0.7 = 360°)
float x = sin(baseSteps * 0.7) * z;
float y = cos(baseSteps * 0.7) * z;

Thank you so much for the time!

1

There are 1 best solutions below

1
On BEST ANSWER

All your $x,y,z$ coordinates in your code are in the plane. The $z$ coordinate (vertical direction) is given by a different motor. Your $x$ and $y$ should also account for the distance from the detector to the center of the turntable ($d$). Suppose $x$ is the direction towards detector when the angle is $0$, and $y$ points to the left as seen from above. If $r$ is the range given by the sensor, then $$x=(d-r)\cos\theta\\y=-(d-r)\sin\theta$$ $\theta$ is the angle of the turntable in radians. The extra $-$ sign for $y$ comes from the fact that if the turntable turns a positive angle, this is equivalent of the detector moving around the sample in the opposite direction. Like I mentioned before, the $z$ height is controlled independently.