# PureBasic Forum

 It is currently Thu Nov 26, 2020 7:14 pm

 All times are UTC + 1 hour

 Page 2 of 2 [ 23 posts ] Go to page Previous  1, 2
 Print view Previous topic | Next topic
Author Message
 Post subject: Re: Procedure to define a best-fit Plane through a set of poPosted: Fri Jan 17, 2020 4:37 am
 Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6261
Location: Wales, UK
I'm working on integrating your code - on average, there are around 70 planes to define (mostly not displayed graphically, they are a means to an end - intersections. If User selection of planes is required, then symbolic square quad faces are displayed.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.

Top

 Post subject: Re: Procedure to define a best-fit Plane through a set of poPosted: Sat Jan 18, 2020 9:14 pm
 Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6261
Location: Wales, UK
Hi again alter Mann

I'm having a torrid time trying to separate the code into what is required to find the best fit plane and the code required to display/rotate/zoom the plane (which I don't need for the plane, it's one of many, but I would like to "recycle" that part of the code to allow the whole model to be rotated/zoomed).

As I understand it:
2) What does adSP() represent? The centroid of the points Bounding Box?

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.

Top

 Post subject: Re: Procedure to define a best-fit Plane through a set of poPosted: Sun Jan 19, 2020 11:28 am
 User

Joined: Fri Oct 17, 2014 8:52 pm
Posts: 39
adMinMax ist the bounding box. adSP is the centroid of all data points. This is not the same as the centroid of the bouning box. The centroid is part of the best-fit plane (see the article you linked above).
adMP is the centroid of the bounding box.
CalcMat calculates the matrix, according to which the eigenvectors and the eigenvalues ​​are calculated. The eigenvector of the minimum of the eigenvalues shows the plane normal vector (also explained in the article).

Top

 Post subject: Re: Procedure to define a best-fit Plane through a set of poPosted: Thu Feb 13, 2020 8:00 pm

Joined: Wed Jun 11, 2003 9:33 pm
Posts: 4645
Location: Spa, relaxing and thinking, and learning...
Interesting problem.
I would proceed in this manner:
Get the 'n' points (3D vectors really).
Get 3 groups (n/3), if 'n' is 40 for example: then 1 group from 13, other 13, and other 14. The groups are obtained randomly i.e. never mind what points.
Locate the "center of masses" from each group, for example for first group would be the arithmetic mean: ' v1+v2+v3... / 13 ' , where v1, v2, etc. are the points (vectors).
So you have now 3 points to build the wanted plane.

Repeat that algorithm adding to the 'n' those above 3 points, and using now a Weighted_arithmetic_mean (https://en.wikipedia.org/wiki/Weighted_arithmetic_mean) giving to the 3 points a bigger "weigth" than the others.

Repeat again. So you will get 46, and the weight for the 3 points is now still bigger.

Repeat again.

The more loops the more accurate plane will obtain.

_________________
http://www.zeitgeistmovie.com

Top

 Post subject: Re: Procedure to define a best-fit Plane through a set of poPosted: Wed Feb 19, 2020 1:55 am
 Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6261
Location: Wales, UK
Hi Psychophanta - I did experiment with a similar method before, but it was not waif and stray proof enough for my purpose. However, it would not be unusual for the cause of failure to be my implementation rather than the method

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.

Top

 Post subject: Re: Procedure to define a best-fit Plane through a set of poPosted: Wed Feb 19, 2020 6:17 pm
 Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6261
Location: Wales, UK
Hi alter Mann

Until now, I have not paid attention to the plane's normal direction, but I discovered I have made errors by not taking it into consideration.

In the best-fit plane code, can I define the normal direction?

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.

Top

 Post subject: Re: Procedure to define a best-fit Plane through a set of poPosted: Wed Feb 19, 2020 9:54 pm
 User

Joined: Fri Oct 17, 2014 8:52 pm
Posts: 39
The point set does not define one direction of the plane but both, the calculated direction (adV()) and the opposite direchtion (-adV(0),-adV(1),-adV(2)). To choose one of both you need additional information.

Top

 Post subject: Re: Procedure to define a best-fit Plane through a set of poPosted: Thu Feb 20, 2020 1:40 am
 Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6261
Location: Wales, UK
Indeed in this case I know the directions required so I have set-up a test for each case, which is working well

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 2 of 2 [ 23 posts ] Go to page Previous  1, 2

 All times are UTC + 1 hour

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forum

Search for:
 Jump to:  Select a forum ------------------ PureBasic    Coding Questions    Game Programming    3D Programming    Assembly Programming    The PureBasic Editor    The PureBasic Form Designer    General Discussion    Feature Requests and Wishlists    Tricks 'n' Tips Bug Reports    Bugs - Windows    Bugs - Linux    Bugs - Mac OSX    Bugs - IDE    Bugs - Documentation OS Specific    AmigaOS    Linux    Windows    Mac OSX Miscellaneous    Announcement    Off Topic Showcase    Applications - Feedback and Discussion    PureFORM & JaPBe    TailBite