POV-Ray : Newsgroups : povray.general : Calculating a plane through a bunch of points Server Time
27 Dec 2024 02:17:57 EST (-0500)
  Calculating a plane through a bunch of points (Message 1 to 7 of 7)  
From: Ger
Subject: Calculating a plane through a bunch of points
Date: 11 Oct 2014 12:19:22
Message: <5439588a@news.povray.org>
I have a set of points, 2 rows side by side of 5 points each. The x and z values are
set in a grid pattern, the y-values vary. I would like to calculate a plane that
averages all 
points in such a way that some points will be above the plane and some will be below
it. The plane itself needs to tilt on the x and z axis in such a way that it gets as
close as 
possible to all points. So it's not going to be a simple plane{ y, 0 translate y *
shiftvalue}

How would I go about doing this?
-- 

Ger


Post a reply to this message

From: Bald Eagle
Subject: Re: Calculating a plane through a bunch of points
Date: 11 Oct 2014 13:00:01
Message: <web.54396135509cb55e7df57c0@news.povray.org>
Can you just run a linear regression on each set of 5 points, and then split the
difference by bisecting the angle between them with the plane?

You might try asking on StackOverflow or Mathematica forums - they have people
over there with WAY too much mathematical talent.


Post a reply to this message

From: Ger
Subject: Re: Calculating a plane through a bunch of points
Date: 11 Oct 2014 14:45:58
Message: <54397ae6@news.povray.org>
Bald Eagle wrote:

> Can you just run a linear regression on each set of 5 points, and then
> split the difference by bisecting the angle between them with the plane?
> 

I just read (part of) the wiki page on linear regression, but since my math knowledge
hovers just above zero that page was mostly gibberish for me.

> You might try asking on StackOverflow or Mathematica forums - they have
> people over there with WAY too much mathematical talent.

-- 

Ger


Post a reply to this message

From: Bald Eagle
Subject: Re: Calculating a plane through a bunch of points
Date: 11 Oct 2014 15:55:01
Message: <web.54398a3f509cb55e7df57c0@news.povray.org>
Ger <No.### [at] ThankYou> wrote:

> I just read (part of) the wiki page on linear regression, but since my math
knowledge hovers just above zero that pag
e was mostly gibberish for me.

Right - I'd have to say that very few people would know how to, or would be
expected to implement, a least-squares regression analysis from scratch.  It's a
button-push feature on a lot of calculators, and it's implemented in
spreadsheets like Excel or Open Office, as well as others.

If it needs to be done on the fly, you might have to see if POV-Ray has the math
functions required to give you what you need.  Otherwise you could generate your
data set with a 3rd party tool, and then run POV-Ray afterwards.

plugging   povray least squares   into Google actually seems to pull up a number
of links that look like they address exactly the problem you are looking for a
solution to.  Surf around some, and maybe you'll hit upon something useful.  Let
me know what you come up with.


Post a reply to this message

From: Nekar Xenos
Subject: Re: Calculating a plane through a bunch of points
Date: 11 Oct 2014 16:51:30
Message: <op.xnk2vvleufxv4h@xena.home>
On Sat, 11 Oct 2014 18:18:40 +0200, Ger <No.### [at] thankyou> wrote:

>
> I have a set of points, 2 rows side by side of 5 points each. The x and  
> z values are set in a grid pattern, the y-values vary. I would like to  
> calculate a plane that averages all
> points in such a way that some points will be above the plane and some  
> will be below it. The plane itself needs to tilt on the x and z axis in  
> such a way that it gets as close as
> possible to all points. So it's not going to be a simple plane{ y, 0  
> translate y * shiftvalue}
>
> How would I go about doing this?

I would think you would have to script something that makes all possible  
triangles from those points. Then calculate each triangle's normal and  
calculate the average normal of all these triangles.
Now you can create a plane and rotate it perpendicular to the average  
normal and then translate it by the average of the coordinates of the  
original points.

-- 
-Nekar Xenos-


Post a reply to this message

From: Ger
Subject: Re: Calculating a plane through a bunch of points
Date: 11 Oct 2014 20:57:53
Message: <5439d211$1@news.povray.org>
Bald Eagle wrote:

> Ger <No.### [at] ThankYou> wrote:
> 
>> I just read (part of) the wiki page on linear regression, but since my
>> math knowledge hovers just above zero that pag
> e was mostly gibberish for me.
> 
> Right - I'd have to say that very few people would know how to, or would
> be
> expected to implement, a least-squares regression analysis from scratch. 
> It's a button-push feature on a lot of calculators, and it's implemented
> in spreadsheets like Excel or Open Office, as well as others.
> 
> If it needs to be done on the fly, you might have to see if POV-Ray has
> the math
> functions required to give you what you need.  Otherwise you could
> generate your data set with a 3rd party tool, and then run POV-Ray
> afterwards.
> 
> plugging   povray least squares   into Google actually seems to pull up a
> number of links that look like they address exactly the problem you are
> looking for a
> solution to.  Surf around some, and maybe you'll hit upon something
> useful.  Let me know what you come up with.

Found a piece of code at

http://stackoverflow.com/questions/10781639/how-to-compute-normal-vector-to-least-square-plane-in-povray-only

Needed some slight tweaking but for as far as I can see now it does its job.

-- 

Ger


Post a reply to this message

From: Jellby
Subject: Re: Calculating a plane through a bunch of points
Date: 12 Oct 2014 04:08:22
Message: <tkopgb-4mo.ln1@meles.unex.es>
On 11/10/14, at 18:18, Ger wrote:
>
> I have a set of points, 2 rows side by side of 5 points each. The x and z values are
set in a grid pattern, the y-values vary. I would like to calculate a plane that
averages all
> points in such a way that some points will be above the plane and some will be below
it. The plane itself needs to tilt on the x and z axis in such a way that it gets as
close as
> possible to all points. So it's not going to be a simple plane{ y, 0 translate y *
shiftvalue}

Does this help?
http://math.stackexchange.com/questions/99299/best-fitting-plane-given-a-set-of-points

The problem now is how to do a SVD in POV-Ray. Or, if you don't need to 
do it within POV-Ray: http://www.bluebit.gr/matrix-calculator/

-- 

             / /\
Linux user / /  \
#289967   / / /\ \ PGP Pub Key
          / / /\ \ \ 0x01A95F99
         / /_/__\ \ \
        /________\ \ \
jellby \___________\/ yahoo.com


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.