|
![](/i/fill.gif) |
I'm graphing some data I obtained in a physics experiment for school and I
have a set of points. I'm trying to find the best fit plane for the set of
points, I tried this algorithim from the book "3D Math Primer for Graphics
and Game Development" but I'm getting strange results and the plane is no
where near what it's supposed to look like.
All the points are already semi-planar so I'm assuming that the plane
shouldn't be orient nearly 90 degrees to the data. I'll post an example of
what going in in p.b.i if my explanation isn't very clear.
#local n = Number of points in array;
//Calculate Best Fit Normal
#local Normal = <0, 0, 0>;
#local P = Points[n-1];
#local i = 0;
#while(i < n)
#local C = Points[i];
#local Normal = Normal + <(P.z+C.z)*(P.y-C.y), (P.x+C.x)*(P.z-C.z),
(P.y+C.y)*(P.x-C.x)>;
#local P = C;
#local i = i + 1;
#end
#local Normal = vnormalize(Normal);
//Calculate the best fit distance
#local Distance = 0;
#local i = 0;
#while(i < n)
#local Distance = Distance + vdot(Points[i], Normal);
#local i = i + 1;
#end
#local Distance = Distance / n;
plane {
Normal, Distance
}
any help with this issue would be greatly appreciated
--
Kevin
http://www.geocities.com/qsquared_1999/
#macro _(r)#if(r<12)#local i=asc(substr("oqshilacefg"
,r,1))-97;disc{<mod(i,7)-3,div(i,7)-1,6>,z,.4
pigment{rgb 10}}_(r+1)#end#end _(1)//KL
Post a reply to this message
|
![](/i/fill.gif) |