LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

(x,y,z) points: is it possible to fit them with a plane?

Solved!
Go to solution

I can measure with a machine the coordinates (x,y,z) of some points that stay in a plane. 

Can I use labview to fit the points and extract the equation of the plane in a x,y,z coordinate system? 

If it were possible please help me, suggesting some example code (if existing...) or at least suggest to me which functions I should use: I even don't know where to start from.

Thanks in advance

0 Kudos
Message 1 of 11
(7,862 Views)

How would you do it if you weren't using LabVIEW but just regular math?

 

From what I recall, vectors and cross products come into play in the calculations.  So look at the Mathematics >> Linear Algebra palette.

 

0 Kudos
Message 2 of 11
(7,852 Views)

But I need to make a best fit with a surface, a plane. The points I measure have an error and I HAVE to do a best fit. 

If I measure (x,y) point staying in a line, I know hot to fit them with a line (regression fit). Now I have point in (x,y,z) space and I need to put a plane fitting them. 

Is it possible to do that or not? 

 

0 Kudos
Message 3 of 11
(7,848 Views)
Message 4 of 11
(7,844 Views)

There is an example VI that ships with LabVIEW 2010 that may be of use to you. It is called the 'B Spline Fitting Demo'. This VI contains an implementation of a 3D curve fitting function that will smooth your (x,y,z) data. However, It will not provide you the equation that best descibes the fit.

 

Regards,

Dave.

Senior Software Engineer
www.Adansor.com
0 Kudos
Message 5 of 11
(7,839 Views)

I had the same problem,

here is a quick and dirty solution....

 

FittingPlane

 

Regards,

Marco

0 Kudos
Message 6 of 11
(7,694 Views)
Solution
Accepted by topic author gnappo

What I actually did is to use the following algorithm which I found googling:

http://www.sbg.bio.ic.ac.uk/~islam/plane.html

It can be implemented with labview very easily.

Message 7 of 11
(7,672 Views)

gnappo, Can you post an example of the vi you used? 

0 Kudos
Message 8 of 11
(6,644 Views)

There are (at least) two ways to think about fitting a plane through a collection of data points.  The reference that you provided solves the general problem of a least-squares fit when there is "uncertainty of measurement" about X, Y, and Z values.

 

However, in many cases, you make measurements of a (Z) value from "known" X and Y settings.  Under this circumstance (which I believe is the case with what you are describing), the "unknown" quantity is X, so what you want to minimize is not the "distance to the best plane" for your cloud of X, Y, Z points, but the Z-distance to the plane.  I grant that this is a subtle distinction, and in the "best of all possible worlds" will give (roughly) the same answer, but if you go to publish your work and state your methods, some sharp-eyed reviewer might pick up that you used the wrong algorithm for fitting, and might question the values of your fit.

 

Bob "Pedantic" Schor

0 Kudos
Message 9 of 11
(6,628 Views)

I am sorry for my late answer. Furthermore, you asked me something I did a long time ago. Anyway, here are the 2 files I used. They are alternative. They are subvi of a large project. However, you can make work each of them as if they were VIs. They calculate the eigenvector. You have to give the points in input in the format you like (so you should modifify all the first part according to your need in order to have the xi, yi and z)i. Unfortunately for you, I write VIs in a spaghetti-like fashion, but I think that if you have clear the formulas to use (the link I gave before) you can easily figure how it works. 

Download All
Message 10 of 11
(6,509 Views)