Multiple constraints for best fit

Discuss Leica Cyclone 3DR software here.
Post Reply
Juliette
I have made <0 posts
I have made <0 posts
Posts: 2
Joined: Wed Jan 25, 2023 10:37 am
Full Name: Juliette Bouche
Company Details: Lehmann Geometre SA
Company Position Title: geomatics engineer
Country: Switzerland
Linkedin Profile: No

Multiple constraints for best fit

Post by Juliette »

Hello,

I'm new with scripting with Javascript for 3DR. I want to automate the extraction of circles on point clouds and I need to constrain both circle radius and normal, but I can't find the correct terminology for applying multiple constraints to a best fit command. Here are my lines of code:

Code: Select all

function bestCircle(iCloud) {
    // Define the parameters of the Best Circle Extraction
    var eliminatePoints = iCloud.GetNumber() * 0.01; // 10% of the points are not considered to extract the best circle
    var force = SCloud.CIRCLE_FORCE_RADIUS & SCloud.CIRCLE_FORCE_NORMAL;
    var centerPoint = SPoint.New(0,0,0);
    var circleNormal = SVector.New(0,0,1);
    var result = iCloud.BestCircle(SCloud.BEST_CIRCLE,eliminatePoints,force,centerPoint,circleNormal,0.175);
fmontoya
I have made <0 posts
I have made <0 posts
Posts: 2
Joined: Wed Jan 25, 2023 12:43 pm
Full Name: Frédérick Montoya
Company Details: Technodigit
Company Position Title: QA technician
Country: France
Linkedin Profile: Yes
Been thanked: 1 time

Re: Multiple constraints for best fit

Post by fmontoya »

Hello Juliette,
Your issue comes from the fact that you give the function a decimal value for the points to eliminate. To solve it, simply use Math.round to get an integer:

Code: Select all

var eliminatePoints = Math.round(iCloud.GetNumber() * 0.01);
Here is a full script that computes a Best Circle with the first cloud in the file:

Code: Select all

var iCloud = SCloud.All()[0];

function bestCircle(iCloud) {
    // Define the parameters of the Best Circle Extraction
    var eliminatePoints = Math.round(iCloud.GetNumber() * 0.01); // 10% of the points are not considered to extract the best circle
    var force = SCloud.CIRCLE_FORCE_RADIUS & SCloud.CIRCLE_FORCE_NORMAL;
    var centerPoint = SPoint.New(0,0,0);
    var circleNormal = SVector.New(0,0,1);
    var result = iCloud.BestCircle(
        SCloud.BEST_CIRCLE,
        eliminatePoints,
        force,
        centerPoint,
        circleNormal,
        0.175);
    print(result.ErrorCode)
    result.Circle.AddToDoc();
};

bestCircle(iCloud)
Hope it helps,
Frédérick
Juliette
I have made <0 posts
I have made <0 posts
Posts: 2
Joined: Wed Jan 25, 2023 10:37 am
Full Name: Juliette Bouche
Company Details: Lehmann Geometre SA
Company Position Title: geomatics engineer
Country: Switzerland
Linkedin Profile: No

Re: Multiple constraints for best fit

Post by Juliette »

Sorry I think I misspoke my question which was mainly about this line :

Code: Select all

var force = SCloud.CIRCLE_FORCE_RADIUS & SCloud.CIRCLE_FORCE_NORMAL;
How to apply these 2 constraints to my circle?
fmontoya
I have made <0 posts
I have made <0 posts
Posts: 2
Joined: Wed Jan 25, 2023 12:43 pm
Full Name: Frédérick Montoya
Company Details: Technodigit
Company Position Title: QA technician
Country: France
Linkedin Profile: Yes
Been thanked: 1 time

Re: Multiple constraints for best fit

Post by fmontoya »

Oops!

Then all you have to do is put a + instead of the &:

Code: Select all

var force = SCloud.CIRCLE_FORCE_RADIUS + SCloud.CIRCLE_FORCE_NORMAL;

Frédérick
Post Reply

Return to “Leica Cyclone 3DR”