Hi, I wrote a two points distance measure tool, I want to extend the feature to be able to pick the point cloud’s point that is within 1mm of the line. Then save those point coordinate into an array.
Here is the code that I wrote in sandcastle. Any logic or code will be appreciated. Thanks
https://sandcastle.cesium.com
Can anyone help me out with this one if possible, many thanks. Any clues, any hints or what so ever is appreciated.
You’ll likely need to iterate through all points in the tiles along the line. To do so for a tile, take a look at processTileFeatures
in this example.
To determine the distance of a point from the line, you can do something like the following, where position
is the point’s Cartesian3 position, and the distance between the end points of the line are l1
and l2
.
const difference = Cesium.Cartesian3.subtract(l2, l1, new Cesium.Cartesian3());
const normal = Cesium.Cartesian3.normalize(difference, difference);
const plane = Cesium.Plane.fromPointNormal(position, normal);
const intersection = IntersectionTests.lineSegmentPlane(plane, l1, l2);
return Cesium.Cartesian3.distance(intersection, point);
Thanks Gabby, I have worked it out.