[vtk-developers] vtkMath::SolveLeastSquares exercised?
Goodwin Lawlor
goodwin.lawlor at ucd.ie
Thu Feb 26 23:12:38 EST 2004
Hi Chris,
Here's some code that fits a quadric to a point cloud (rpoints) with
nsize points. Matrix and MakeZero are macros stolen from
vtkSurfaceReconstructionFilter (now called vtkSRMatrix and
vtkSRMakeZero). I've tested it with some synthetic data and it works
ok...
//Fit a quadric a(x.x) + b(x.y) + c(y.y)
double **X, **Y, **M;
X = Matrix(0,nsize -1,0,2);
Y = Matrix(0,nsize -1,0,0);
M = Matrix(0,2,0,0);
MakeZero(M,0,2,0,0);
for (j=0;j<nsize ;j++ )
{
rpoints->GetPoint(j,rp);
X[j][0] = rp[0]*rp[0]; //x*x
X[j][1] = rp[0]*rp[1]; //x*y
X[j][2] = rp[1]*rp[1]; //y*y
Y[j][0] = rp[2]; // z
}
vtkMath::SolveLeastSquares(nsize, X , 3, Y, 1, M );
a = M[0][0]; b = M[1][0]; c = M[2][0];
HTH
Goodwin
-----Original Message-----
From: vtk-developers-admin at vtk.org [mailto:vtk-developers-admin at vtk.org]
On Behalf Of Chris Volpe
Sent: 27 February 2004 01:19
To: vtk-developers at vtk.org
Subject: [vtk-developers] vtkMath::SolveLeastSquares exercised?
Does anybody have any code that exercises the method
vtkMath::SolveLeastSquares added by Tony Pan? I have a system of about
32 equations in 12 unknowns, which should, for the most part, be
independent. But it's not able to construct the pseudo-inverse. I
already found one bug, a minor memory management bug in which the
three-parameter InvertMatrix method wasn't allocating dynamic storage
for index and column when size>10 (I'll be checking in that fix when I
get past this current problem), so that leads me to believe this code
isn't being exercised, at least not for larger systems.
Thanks a bunch in advance.
Chris
--
Christopher R. Volpe, Ph.D.
Senior Scientist
Email: cvolpe at ara.com
Applied Research Associates, Inc. Voice:
919-582-3380
8540 Colonnade Center Dr., Ste 301
Fax: 919-878-3672
Raleigh, NC 27615
Web: www.ara.com
More information about the vtk-developers
mailing list