Procedure to define a best-fit Plane through a set of points

Everything related to 3D programming
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Procedure to define a best-fit Plane through a set of po

Post by IdeasVacuum »

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.
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Procedure to define a best-fit Plane through a set of po

Post by IdeasVacuum »

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:
1) In Procedure Main, DATcalcSize(adPoints(),adMinMax(),adSP()) defines the Bounding Box of the points?
2) What does adSP() represent? The centroid of the points Bounding Box?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
alter Mann
User
User
Posts: 39
Joined: Fri Oct 17, 2014 8:52 pm

Re: Procedure to define a best-fit Plane through a set of po

Post by alter Mann »

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).
Hope this help you a little bit.
User avatar
Psychophanta
Addict
Addict
Posts: 4996
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Re: Procedure to define a best-fit Plane through a set of po

Post by Psychophanta »

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

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen:
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Procedure to define a best-fit Plane through a set of po

Post by IdeasVacuum »

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 :wink:
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Procedure to define a best-fit Plane through a set of po

Post by IdeasVacuum »

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.
alter Mann
User
User
Posts: 39
Joined: Fri Oct 17, 2014 8:52 pm

Re: Procedure to define a best-fit Plane through a set of po

Post by alter Mann »

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.
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Procedure to define a best-fit Plane through a set of po

Post by IdeasVacuum »

Indeed in this case I know the directions required so I have set-up a test for each case, which is working well :D
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply