Search code examples
javascriptthree.jspoint-clouds

Potree/Three.js measuring questions


Firstly, I'm newbie and non-native speak english, sorry.

In this moment, I work with multiple ( and differents ) point clouds loaded in the same page with the awesome Potree 1.4RC, but I want to read the height of a point cloud automatically, I mean, that reading all points of cloud and detect max dimension. I have worked with:

Var Potree.Measure areaMeasurement = new ( ) ;
areaMeasurement.addMarker (new THREE.Vector3 (0, 0 , 0)) ;
areaMeasurement.addMarker (new THREE.Vector3 ( -10 , 0 , 0 ) ) ;
viewer.measuringTool.addMeasurement ( areaMeasurement ) ;

But my points are predefined... my question is how can I do to obtain the maximum height or width of a PointCloud ( not bounding box )?

Otherwise, how can I obtain a spatial coordinate (p.e: Z) when I give the others (p.e.: X and Y) in Potree or Three.js? Would be possible auto detect this maximums and obtain her coordinates?

A lot of thanks, Best regards.


Solution

  • You can get a maximum width by computing the squared-distances between every pair ( x, z ) of points in your point cloud

    distanceSquared = ( v1.x - v2.x ) * ( v1.x - v2.x ) + ( v1.z - v2.z ) * ( v1.z - v2.z );
    

    and then selecting the square-root of the maximum value.

    The maximum height is just the largest y-coordinate of the points.