[SciPy-user] Fitting Problem with line in 3D-space

Charles Monty Burns ch.monty.burns at googlemail.com
Sat Nov 8 08:33:22 EST 2008


Tanks for your replay.

Can you test your code with that points http://pastebin.mozilla.org/570655 .
The result should be the direction vector (0, 0, 1). I construct this points
with direction vector on z-axis.

Greetings

On Sat, Nov 8, 2008 at 1:59 PM, Pauli Virtanen <pav at iki.fi> wrote:

> Sat, 08 Nov 2008 03:53:39 +0100, Charles Monty Burns wrote:
>
> > Hello,
> >
> > I am trying to get an axis of a cylinder in 3D-space using the leastsq
> > method.
> >
> > My modell-equation is:
> >
> > \vec u \times (\vec r - \vec r_0) = \vec 0
> >
> > u ... the direction vector
> > r ... the independent vector
> > r_0 ... one position vector on the line
> >
> > Can somebody tell me how to construct the functions leastsq is need?
> >
> > With simple function like y=x*... its very simple ... but not with that
> > line
>
> Like this, for example:
>
> -----------------------------------------
> from scipy.optimize import leastsq
> import numpy as np
>
> points = np.loadtxt('points.dat') # data file with 3 columns
>
> def params(p):
>    return p[:3]/np.linalg.norm(p[:3]), p[3:]
>
> def model(p):
>    u, v0 = params(p)
>    return np.cross(points - v0, u).ravel()
>
> result, ier = leastsq(model, [1, 0, 0, 0, 0, 0])
> u, v0 = params(result)
>
> print u
> print v0
> -----------------------------------------
>
> --
> Pauli Virtanen
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20081108/94f040de/attachment.html>


More information about the SciPy-User mailing list