Stumbled upon it by pure chance.
Does the Rw imply that it comes from Realworks or has it something to do with Railway?
It comes with some interesting Classes, which make it really simple to compute best fit planes. Might be useful for you, Fernando.
A long time ago have been experimenting with the external MathNet library in order to compute the SVD, but you need to setup the matrices and linear solver the right way, rather complicate.
Now you just need to throw a list with points onto FitPlaneTo3DPoints.
# the Plane3D and Point3D struct are unfortunately different
clr.AddReference ("Trimble.Rw.Core")
from Trimble.Rw.Core.VectorMath.Geometry import Plane3D as RwPlane3D
from Trimble.Rw.Core.VectorMath import Point3D as RwPoint3D
rwcloudpoints = []
for o in selectionSet:
if isinstance(o, self.pointcloudType):
cps = o.Integration.PointCloudDatabase.Integration.GetPoints(o.Integration.GetSelectedCloudId())
for p in cps:
rwcloudpoints.Add(RwPoint3D(p.X, p.Y, p.Z)) # adding as Rw type Point3D
rwplane = RwPlane3D.FitPlaneTo3DPoints(rwcloudpoints)
# converting back to our usual Trimble.Vce.Geometry struct types
centerp = Point3D(rwplane.Point.X, rwplane.Point.Y, rwplane.Point.Z)
v = Vector3D(rwplane.NormalVector.X, rwplane.NormalVector.Y, rwplane.NormalVector.Z)
Makes it simple to create a best fit planar surface into a bunch of pickup points, something I had been missing just recently.
slope = wv.Add(clr.GetClrType(SlopingLevelSurface))
slope.Name = Model3D.GetUniqueName("Testslope", None, wv) #make sure name is unique
slope.BoundarySerialNumber = l.SerialNumber
slope.ElevationSlopeType = ElevationSlopeTypes.PointAndDirection
slope.Point1 = centerp
slope.Point2 = centerp + v
slope.Azimuth = v.Azimuth
slope.LeftInclination = 0
slope.RightInclination = 0
slope.Slope = v.Horizon + math.pi/2


------------------------------
Ronny Schneider
------------------------------