Determining whether a large series of 3D points all line on a plane












0












$begingroup$


TL;DR: For a large series of precise 3D coordinates that describe a real-world orbit, how can we determine if they all lie exactly on a plane?



The Problem



I've used NASA's highly precise SPICE toolkit to calculate the hourly position of the moon relative to the Earth in Cartesian coordinates. The frame of reference for these points is the J2000 frame: Earth's equator (x and y), with the z-axis running orthogonally through the poles.



We know the moon's orbit does not lie on the equatorial plane. The Earth-Moon orbit is typically described as a plane that is 5.14 degrees inclined from the equatorial plane.



enter image description here



(This is a 28-day period from Jan. 2018, hence the small overlap since the sidereal month is 27.32 days.)



What I want to determine is whether this orbit is perfectly "flat" -- whether the Moon orbits the Earth on a perfect plane rotated from the terrestrial equator -- or whether there is even a slight variance on the z axis of this approximate Earth-Moon orbital plane.



It's certainly very close to a plane, as we'd expect, as you can see from a year's worth of z coordinates from the Earth's frame of reference. But orbit's are hugely complicated given all the possible aberrations, which the SPICE toolkit usually accounts for.



enter image description here



One idea I had was to choose three points in the orbit, spaced about 9 days apart, calculate the plane for those three points, and then calculate the distance from that plane for each point. This seems inelegant and possibly biased by which three points I choose, though in theory all I need to know is whether the distance of each point to the 3-point plane is zero, regardless of which three points define the plane.



It seems to me there is a more elegant solution than this brute-force approach?










share|cite|improve this question









$endgroup$








  • 1




    $begingroup$
    Sounds fun! Though, almost certainly the points don't lie "exactly" on a plane. I'd recommend finding the plane that is closest to all the points in the least square sense. There are a couple of approaches to this described in the answers to this question. You can then use the average of the residuals to have an estimate as to how close the points are to planar. This would be similar to your three point solution but avoid the problem of bias that you are correctly concerned about.
    $endgroup$
    – Mark McClure
    Dec 6 '18 at 18:43










  • $begingroup$
    Thank you! There's even Python code in the link -- lucky me! (And I agree -- it would be suspiciously elegant for the Moon not to wobble even a few millimeters, though probably more than that)
    $endgroup$
    – Chris Wilson
    Dec 6 '18 at 18:49










  • $begingroup$
    They don't lie exactly in a plane.
    $endgroup$
    – Yves Daoust
    Dec 6 '18 at 19:17
















0












$begingroup$


TL;DR: For a large series of precise 3D coordinates that describe a real-world orbit, how can we determine if they all lie exactly on a plane?



The Problem



I've used NASA's highly precise SPICE toolkit to calculate the hourly position of the moon relative to the Earth in Cartesian coordinates. The frame of reference for these points is the J2000 frame: Earth's equator (x and y), with the z-axis running orthogonally through the poles.



We know the moon's orbit does not lie on the equatorial plane. The Earth-Moon orbit is typically described as a plane that is 5.14 degrees inclined from the equatorial plane.



enter image description here



(This is a 28-day period from Jan. 2018, hence the small overlap since the sidereal month is 27.32 days.)



What I want to determine is whether this orbit is perfectly "flat" -- whether the Moon orbits the Earth on a perfect plane rotated from the terrestrial equator -- or whether there is even a slight variance on the z axis of this approximate Earth-Moon orbital plane.



It's certainly very close to a plane, as we'd expect, as you can see from a year's worth of z coordinates from the Earth's frame of reference. But orbit's are hugely complicated given all the possible aberrations, which the SPICE toolkit usually accounts for.



enter image description here



One idea I had was to choose three points in the orbit, spaced about 9 days apart, calculate the plane for those three points, and then calculate the distance from that plane for each point. This seems inelegant and possibly biased by which three points I choose, though in theory all I need to know is whether the distance of each point to the 3-point plane is zero, regardless of which three points define the plane.



It seems to me there is a more elegant solution than this brute-force approach?










share|cite|improve this question









$endgroup$








  • 1




    $begingroup$
    Sounds fun! Though, almost certainly the points don't lie "exactly" on a plane. I'd recommend finding the plane that is closest to all the points in the least square sense. There are a couple of approaches to this described in the answers to this question. You can then use the average of the residuals to have an estimate as to how close the points are to planar. This would be similar to your three point solution but avoid the problem of bias that you are correctly concerned about.
    $endgroup$
    – Mark McClure
    Dec 6 '18 at 18:43










  • $begingroup$
    Thank you! There's even Python code in the link -- lucky me! (And I agree -- it would be suspiciously elegant for the Moon not to wobble even a few millimeters, though probably more than that)
    $endgroup$
    – Chris Wilson
    Dec 6 '18 at 18:49










  • $begingroup$
    They don't lie exactly in a plane.
    $endgroup$
    – Yves Daoust
    Dec 6 '18 at 19:17














0












0








0





$begingroup$


TL;DR: For a large series of precise 3D coordinates that describe a real-world orbit, how can we determine if they all lie exactly on a plane?



The Problem



I've used NASA's highly precise SPICE toolkit to calculate the hourly position of the moon relative to the Earth in Cartesian coordinates. The frame of reference for these points is the J2000 frame: Earth's equator (x and y), with the z-axis running orthogonally through the poles.



We know the moon's orbit does not lie on the equatorial plane. The Earth-Moon orbit is typically described as a plane that is 5.14 degrees inclined from the equatorial plane.



enter image description here



(This is a 28-day period from Jan. 2018, hence the small overlap since the sidereal month is 27.32 days.)



What I want to determine is whether this orbit is perfectly "flat" -- whether the Moon orbits the Earth on a perfect plane rotated from the terrestrial equator -- or whether there is even a slight variance on the z axis of this approximate Earth-Moon orbital plane.



It's certainly very close to a plane, as we'd expect, as you can see from a year's worth of z coordinates from the Earth's frame of reference. But orbit's are hugely complicated given all the possible aberrations, which the SPICE toolkit usually accounts for.



enter image description here



One idea I had was to choose three points in the orbit, spaced about 9 days apart, calculate the plane for those three points, and then calculate the distance from that plane for each point. This seems inelegant and possibly biased by which three points I choose, though in theory all I need to know is whether the distance of each point to the 3-point plane is zero, regardless of which three points define the plane.



It seems to me there is a more elegant solution than this brute-force approach?










share|cite|improve this question









$endgroup$




TL;DR: For a large series of precise 3D coordinates that describe a real-world orbit, how can we determine if they all lie exactly on a plane?



The Problem



I've used NASA's highly precise SPICE toolkit to calculate the hourly position of the moon relative to the Earth in Cartesian coordinates. The frame of reference for these points is the J2000 frame: Earth's equator (x and y), with the z-axis running orthogonally through the poles.



We know the moon's orbit does not lie on the equatorial plane. The Earth-Moon orbit is typically described as a plane that is 5.14 degrees inclined from the equatorial plane.



enter image description here



(This is a 28-day period from Jan. 2018, hence the small overlap since the sidereal month is 27.32 days.)



What I want to determine is whether this orbit is perfectly "flat" -- whether the Moon orbits the Earth on a perfect plane rotated from the terrestrial equator -- or whether there is even a slight variance on the z axis of this approximate Earth-Moon orbital plane.



It's certainly very close to a plane, as we'd expect, as you can see from a year's worth of z coordinates from the Earth's frame of reference. But orbit's are hugely complicated given all the possible aberrations, which the SPICE toolkit usually accounts for.



enter image description here



One idea I had was to choose three points in the orbit, spaced about 9 days apart, calculate the plane for those three points, and then calculate the distance from that plane for each point. This seems inelegant and possibly biased by which three points I choose, though in theory all I need to know is whether the distance of each point to the 3-point plane is zero, regardless of which three points define the plane.



It seems to me there is a more elegant solution than this brute-force approach?







3d plane-geometry mathematical-astronomy






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Dec 6 '18 at 18:34









Chris WilsonChris Wilson

1221110




1221110








  • 1




    $begingroup$
    Sounds fun! Though, almost certainly the points don't lie "exactly" on a plane. I'd recommend finding the plane that is closest to all the points in the least square sense. There are a couple of approaches to this described in the answers to this question. You can then use the average of the residuals to have an estimate as to how close the points are to planar. This would be similar to your three point solution but avoid the problem of bias that you are correctly concerned about.
    $endgroup$
    – Mark McClure
    Dec 6 '18 at 18:43










  • $begingroup$
    Thank you! There's even Python code in the link -- lucky me! (And I agree -- it would be suspiciously elegant for the Moon not to wobble even a few millimeters, though probably more than that)
    $endgroup$
    – Chris Wilson
    Dec 6 '18 at 18:49










  • $begingroup$
    They don't lie exactly in a plane.
    $endgroup$
    – Yves Daoust
    Dec 6 '18 at 19:17














  • 1




    $begingroup$
    Sounds fun! Though, almost certainly the points don't lie "exactly" on a plane. I'd recommend finding the plane that is closest to all the points in the least square sense. There are a couple of approaches to this described in the answers to this question. You can then use the average of the residuals to have an estimate as to how close the points are to planar. This would be similar to your three point solution but avoid the problem of bias that you are correctly concerned about.
    $endgroup$
    – Mark McClure
    Dec 6 '18 at 18:43










  • $begingroup$
    Thank you! There's even Python code in the link -- lucky me! (And I agree -- it would be suspiciously elegant for the Moon not to wobble even a few millimeters, though probably more than that)
    $endgroup$
    – Chris Wilson
    Dec 6 '18 at 18:49










  • $begingroup$
    They don't lie exactly in a plane.
    $endgroup$
    – Yves Daoust
    Dec 6 '18 at 19:17








1




1




$begingroup$
Sounds fun! Though, almost certainly the points don't lie "exactly" on a plane. I'd recommend finding the plane that is closest to all the points in the least square sense. There are a couple of approaches to this described in the answers to this question. You can then use the average of the residuals to have an estimate as to how close the points are to planar. This would be similar to your three point solution but avoid the problem of bias that you are correctly concerned about.
$endgroup$
– Mark McClure
Dec 6 '18 at 18:43




$begingroup$
Sounds fun! Though, almost certainly the points don't lie "exactly" on a plane. I'd recommend finding the plane that is closest to all the points in the least square sense. There are a couple of approaches to this described in the answers to this question. You can then use the average of the residuals to have an estimate as to how close the points are to planar. This would be similar to your three point solution but avoid the problem of bias that you are correctly concerned about.
$endgroup$
– Mark McClure
Dec 6 '18 at 18:43












$begingroup$
Thank you! There's even Python code in the link -- lucky me! (And I agree -- it would be suspiciously elegant for the Moon not to wobble even a few millimeters, though probably more than that)
$endgroup$
– Chris Wilson
Dec 6 '18 at 18:49




$begingroup$
Thank you! There's even Python code in the link -- lucky me! (And I agree -- it would be suspiciously elegant for the Moon not to wobble even a few millimeters, though probably more than that)
$endgroup$
– Chris Wilson
Dec 6 '18 at 18:49












$begingroup$
They don't lie exactly in a plane.
$endgroup$
– Yves Daoust
Dec 6 '18 at 19:17




$begingroup$
They don't lie exactly in a plane.
$endgroup$
– Yves Daoust
Dec 6 '18 at 19:17










2 Answers
2






active

oldest

votes


















1












$begingroup$

Let's say that you have position vectors ${p_i:iin I}subset mathbb R^3$. If they were coplanar, you would have a vector $vinmathbb R^3$ such that $vcdot p_i=0$ for every $iin I$. Since this does not necessarily exist, what you can do instead is minimize the quadratic function
$$
f(v) = sum_{iin I} (vcdot p_i)^2
$$

over $vin S^2$.



This gives a good candidate for the "average orbit normal".



Edit 1: you have to subtract the barycenter of the points $p_i$ first, if you want the problem to be translation invariant.



Edit 2: the gradient of $f$ can be computed easily and is
$$
nabla f(v) = 2sum_{iin I} (vcdot p_i)p_i = 2left(sum_{iin I}p_iotimes p_iright)v.
$$

With Lagrange multipliers, you want to find $vin S^2$ and $lambdainmathbb R$ such that $nabla f(v)=2lambda v$, because the constraint is $vcdot v=1$. This is equivalent to finding the eigenvalues of the $3times3$ matrix $sum_{iin I}p_iotimes p_i$.



Edit 3: alternatively, call $P=sum_{iin I}p_iotimes p_i$ and notice that $f(v)=v^TPv$. Therefore the minimum on $S^2$ is achieved at the eigenvectors corresponding to the lowest eigenvalue of $P$.



Edit 4: here is a picture of some points, the plane, the unit normal, and the segments indicating the distances of the points to the plane:





Edit 5: here is some Python code performing the computation



import numpy as np

# 120 random points in 3D
p = np.random.randn(120, 3)

# compute the svd
u, s, vh = np.linalg.svd(p, full_matrices=False)

# the best normal is the last row of vh
n = vh[-1]

# the sum of the squared distances is the square of the last singular value
sum_of_squared_distances = s[-1]**2

# verify the last statement
np.allclose((p@n) @ (p@n), s[-1]**2)





share|cite|improve this answer











$endgroup$













  • $begingroup$
    Interesting! Forgive my rusty memory here, but what is the space S below the equation? Thanks much
    $endgroup$
    – Chris Wilson
    Dec 6 '18 at 19:07






  • 1




    $begingroup$
    The unit sphere in $mathbb R^3$. That's because you want your normal vector to be of unit length. Otherwise the global minimum would be $0$, attained for $v=0$.
    $endgroup$
    – Federico
    Dec 6 '18 at 19:09








  • 1




    $begingroup$
    @ChrisWilson I've added some more details, to show that the problem is equivalent to finding the smallest eigenvalue of a $3times3$ symmetic matrix.
    $endgroup$
    – Federico
    Dec 6 '18 at 19:31






  • 1




    $begingroup$
    Also, in case anyone wonders, $votimes w=vw^T$ is the outer product
    $endgroup$
    – Federico
    Dec 6 '18 at 19:38



















-1












$begingroup$

There don't seem to be outliers, you can use a total-least-squares plane fitting (it gives three solutions but the true one is easy to discriminate).



Then compute the distances to that plane.






share|cite|improve this answer









$endgroup$













    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "69"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3028869%2fdetermining-whether-a-large-series-of-3d-points-all-line-on-a-plane%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1












    $begingroup$

    Let's say that you have position vectors ${p_i:iin I}subset mathbb R^3$. If they were coplanar, you would have a vector $vinmathbb R^3$ such that $vcdot p_i=0$ for every $iin I$. Since this does not necessarily exist, what you can do instead is minimize the quadratic function
    $$
    f(v) = sum_{iin I} (vcdot p_i)^2
    $$

    over $vin S^2$.



    This gives a good candidate for the "average orbit normal".



    Edit 1: you have to subtract the barycenter of the points $p_i$ first, if you want the problem to be translation invariant.



    Edit 2: the gradient of $f$ can be computed easily and is
    $$
    nabla f(v) = 2sum_{iin I} (vcdot p_i)p_i = 2left(sum_{iin I}p_iotimes p_iright)v.
    $$

    With Lagrange multipliers, you want to find $vin S^2$ and $lambdainmathbb R$ such that $nabla f(v)=2lambda v$, because the constraint is $vcdot v=1$. This is equivalent to finding the eigenvalues of the $3times3$ matrix $sum_{iin I}p_iotimes p_i$.



    Edit 3: alternatively, call $P=sum_{iin I}p_iotimes p_i$ and notice that $f(v)=v^TPv$. Therefore the minimum on $S^2$ is achieved at the eigenvectors corresponding to the lowest eigenvalue of $P$.



    Edit 4: here is a picture of some points, the plane, the unit normal, and the segments indicating the distances of the points to the plane:





    Edit 5: here is some Python code performing the computation



    import numpy as np

    # 120 random points in 3D
    p = np.random.randn(120, 3)

    # compute the svd
    u, s, vh = np.linalg.svd(p, full_matrices=False)

    # the best normal is the last row of vh
    n = vh[-1]

    # the sum of the squared distances is the square of the last singular value
    sum_of_squared_distances = s[-1]**2

    # verify the last statement
    np.allclose((p@n) @ (p@n), s[-1]**2)





    share|cite|improve this answer











    $endgroup$













    • $begingroup$
      Interesting! Forgive my rusty memory here, but what is the space S below the equation? Thanks much
      $endgroup$
      – Chris Wilson
      Dec 6 '18 at 19:07






    • 1




      $begingroup$
      The unit sphere in $mathbb R^3$. That's because you want your normal vector to be of unit length. Otherwise the global minimum would be $0$, attained for $v=0$.
      $endgroup$
      – Federico
      Dec 6 '18 at 19:09








    • 1




      $begingroup$
      @ChrisWilson I've added some more details, to show that the problem is equivalent to finding the smallest eigenvalue of a $3times3$ symmetic matrix.
      $endgroup$
      – Federico
      Dec 6 '18 at 19:31






    • 1




      $begingroup$
      Also, in case anyone wonders, $votimes w=vw^T$ is the outer product
      $endgroup$
      – Federico
      Dec 6 '18 at 19:38
















    1












    $begingroup$

    Let's say that you have position vectors ${p_i:iin I}subset mathbb R^3$. If they were coplanar, you would have a vector $vinmathbb R^3$ such that $vcdot p_i=0$ for every $iin I$. Since this does not necessarily exist, what you can do instead is minimize the quadratic function
    $$
    f(v) = sum_{iin I} (vcdot p_i)^2
    $$

    over $vin S^2$.



    This gives a good candidate for the "average orbit normal".



    Edit 1: you have to subtract the barycenter of the points $p_i$ first, if you want the problem to be translation invariant.



    Edit 2: the gradient of $f$ can be computed easily and is
    $$
    nabla f(v) = 2sum_{iin I} (vcdot p_i)p_i = 2left(sum_{iin I}p_iotimes p_iright)v.
    $$

    With Lagrange multipliers, you want to find $vin S^2$ and $lambdainmathbb R$ such that $nabla f(v)=2lambda v$, because the constraint is $vcdot v=1$. This is equivalent to finding the eigenvalues of the $3times3$ matrix $sum_{iin I}p_iotimes p_i$.



    Edit 3: alternatively, call $P=sum_{iin I}p_iotimes p_i$ and notice that $f(v)=v^TPv$. Therefore the minimum on $S^2$ is achieved at the eigenvectors corresponding to the lowest eigenvalue of $P$.



    Edit 4: here is a picture of some points, the plane, the unit normal, and the segments indicating the distances of the points to the plane:





    Edit 5: here is some Python code performing the computation



    import numpy as np

    # 120 random points in 3D
    p = np.random.randn(120, 3)

    # compute the svd
    u, s, vh = np.linalg.svd(p, full_matrices=False)

    # the best normal is the last row of vh
    n = vh[-1]

    # the sum of the squared distances is the square of the last singular value
    sum_of_squared_distances = s[-1]**2

    # verify the last statement
    np.allclose((p@n) @ (p@n), s[-1]**2)





    share|cite|improve this answer











    $endgroup$













    • $begingroup$
      Interesting! Forgive my rusty memory here, but what is the space S below the equation? Thanks much
      $endgroup$
      – Chris Wilson
      Dec 6 '18 at 19:07






    • 1




      $begingroup$
      The unit sphere in $mathbb R^3$. That's because you want your normal vector to be of unit length. Otherwise the global minimum would be $0$, attained for $v=0$.
      $endgroup$
      – Federico
      Dec 6 '18 at 19:09








    • 1




      $begingroup$
      @ChrisWilson I've added some more details, to show that the problem is equivalent to finding the smallest eigenvalue of a $3times3$ symmetic matrix.
      $endgroup$
      – Federico
      Dec 6 '18 at 19:31






    • 1




      $begingroup$
      Also, in case anyone wonders, $votimes w=vw^T$ is the outer product
      $endgroup$
      – Federico
      Dec 6 '18 at 19:38














    1












    1








    1





    $begingroup$

    Let's say that you have position vectors ${p_i:iin I}subset mathbb R^3$. If they were coplanar, you would have a vector $vinmathbb R^3$ such that $vcdot p_i=0$ for every $iin I$. Since this does not necessarily exist, what you can do instead is minimize the quadratic function
    $$
    f(v) = sum_{iin I} (vcdot p_i)^2
    $$

    over $vin S^2$.



    This gives a good candidate for the "average orbit normal".



    Edit 1: you have to subtract the barycenter of the points $p_i$ first, if you want the problem to be translation invariant.



    Edit 2: the gradient of $f$ can be computed easily and is
    $$
    nabla f(v) = 2sum_{iin I} (vcdot p_i)p_i = 2left(sum_{iin I}p_iotimes p_iright)v.
    $$

    With Lagrange multipliers, you want to find $vin S^2$ and $lambdainmathbb R$ such that $nabla f(v)=2lambda v$, because the constraint is $vcdot v=1$. This is equivalent to finding the eigenvalues of the $3times3$ matrix $sum_{iin I}p_iotimes p_i$.



    Edit 3: alternatively, call $P=sum_{iin I}p_iotimes p_i$ and notice that $f(v)=v^TPv$. Therefore the minimum on $S^2$ is achieved at the eigenvectors corresponding to the lowest eigenvalue of $P$.



    Edit 4: here is a picture of some points, the plane, the unit normal, and the segments indicating the distances of the points to the plane:





    Edit 5: here is some Python code performing the computation



    import numpy as np

    # 120 random points in 3D
    p = np.random.randn(120, 3)

    # compute the svd
    u, s, vh = np.linalg.svd(p, full_matrices=False)

    # the best normal is the last row of vh
    n = vh[-1]

    # the sum of the squared distances is the square of the last singular value
    sum_of_squared_distances = s[-1]**2

    # verify the last statement
    np.allclose((p@n) @ (p@n), s[-1]**2)





    share|cite|improve this answer











    $endgroup$



    Let's say that you have position vectors ${p_i:iin I}subset mathbb R^3$. If they were coplanar, you would have a vector $vinmathbb R^3$ such that $vcdot p_i=0$ for every $iin I$. Since this does not necessarily exist, what you can do instead is minimize the quadratic function
    $$
    f(v) = sum_{iin I} (vcdot p_i)^2
    $$

    over $vin S^2$.



    This gives a good candidate for the "average orbit normal".



    Edit 1: you have to subtract the barycenter of the points $p_i$ first, if you want the problem to be translation invariant.



    Edit 2: the gradient of $f$ can be computed easily and is
    $$
    nabla f(v) = 2sum_{iin I} (vcdot p_i)p_i = 2left(sum_{iin I}p_iotimes p_iright)v.
    $$

    With Lagrange multipliers, you want to find $vin S^2$ and $lambdainmathbb R$ such that $nabla f(v)=2lambda v$, because the constraint is $vcdot v=1$. This is equivalent to finding the eigenvalues of the $3times3$ matrix $sum_{iin I}p_iotimes p_i$.



    Edit 3: alternatively, call $P=sum_{iin I}p_iotimes p_i$ and notice that $f(v)=v^TPv$. Therefore the minimum on $S^2$ is achieved at the eigenvectors corresponding to the lowest eigenvalue of $P$.



    Edit 4: here is a picture of some points, the plane, the unit normal, and the segments indicating the distances of the points to the plane:





    Edit 5: here is some Python code performing the computation



    import numpy as np

    # 120 random points in 3D
    p = np.random.randn(120, 3)

    # compute the svd
    u, s, vh = np.linalg.svd(p, full_matrices=False)

    # the best normal is the last row of vh
    n = vh[-1]

    # the sum of the squared distances is the square of the last singular value
    sum_of_squared_distances = s[-1]**2

    # verify the last statement
    np.allclose((p@n) @ (p@n), s[-1]**2)






    share|cite|improve this answer














    share|cite|improve this answer



    share|cite|improve this answer








    edited Dec 7 '18 at 13:53

























    answered Dec 6 '18 at 18:59









    FedericoFederico

    5,144514




    5,144514












    • $begingroup$
      Interesting! Forgive my rusty memory here, but what is the space S below the equation? Thanks much
      $endgroup$
      – Chris Wilson
      Dec 6 '18 at 19:07






    • 1




      $begingroup$
      The unit sphere in $mathbb R^3$. That's because you want your normal vector to be of unit length. Otherwise the global minimum would be $0$, attained for $v=0$.
      $endgroup$
      – Federico
      Dec 6 '18 at 19:09








    • 1




      $begingroup$
      @ChrisWilson I've added some more details, to show that the problem is equivalent to finding the smallest eigenvalue of a $3times3$ symmetic matrix.
      $endgroup$
      – Federico
      Dec 6 '18 at 19:31






    • 1




      $begingroup$
      Also, in case anyone wonders, $votimes w=vw^T$ is the outer product
      $endgroup$
      – Federico
      Dec 6 '18 at 19:38


















    • $begingroup$
      Interesting! Forgive my rusty memory here, but what is the space S below the equation? Thanks much
      $endgroup$
      – Chris Wilson
      Dec 6 '18 at 19:07






    • 1




      $begingroup$
      The unit sphere in $mathbb R^3$. That's because you want your normal vector to be of unit length. Otherwise the global minimum would be $0$, attained for $v=0$.
      $endgroup$
      – Federico
      Dec 6 '18 at 19:09








    • 1




      $begingroup$
      @ChrisWilson I've added some more details, to show that the problem is equivalent to finding the smallest eigenvalue of a $3times3$ symmetic matrix.
      $endgroup$
      – Federico
      Dec 6 '18 at 19:31






    • 1




      $begingroup$
      Also, in case anyone wonders, $votimes w=vw^T$ is the outer product
      $endgroup$
      – Federico
      Dec 6 '18 at 19:38
















    $begingroup$
    Interesting! Forgive my rusty memory here, but what is the space S below the equation? Thanks much
    $endgroup$
    – Chris Wilson
    Dec 6 '18 at 19:07




    $begingroup$
    Interesting! Forgive my rusty memory here, but what is the space S below the equation? Thanks much
    $endgroup$
    – Chris Wilson
    Dec 6 '18 at 19:07




    1




    1




    $begingroup$
    The unit sphere in $mathbb R^3$. That's because you want your normal vector to be of unit length. Otherwise the global minimum would be $0$, attained for $v=0$.
    $endgroup$
    – Federico
    Dec 6 '18 at 19:09






    $begingroup$
    The unit sphere in $mathbb R^3$. That's because you want your normal vector to be of unit length. Otherwise the global minimum would be $0$, attained for $v=0$.
    $endgroup$
    – Federico
    Dec 6 '18 at 19:09






    1




    1




    $begingroup$
    @ChrisWilson I've added some more details, to show that the problem is equivalent to finding the smallest eigenvalue of a $3times3$ symmetic matrix.
    $endgroup$
    – Federico
    Dec 6 '18 at 19:31




    $begingroup$
    @ChrisWilson I've added some more details, to show that the problem is equivalent to finding the smallest eigenvalue of a $3times3$ symmetic matrix.
    $endgroup$
    – Federico
    Dec 6 '18 at 19:31




    1




    1




    $begingroup$
    Also, in case anyone wonders, $votimes w=vw^T$ is the outer product
    $endgroup$
    – Federico
    Dec 6 '18 at 19:38




    $begingroup$
    Also, in case anyone wonders, $votimes w=vw^T$ is the outer product
    $endgroup$
    – Federico
    Dec 6 '18 at 19:38











    -1












    $begingroup$

    There don't seem to be outliers, you can use a total-least-squares plane fitting (it gives three solutions but the true one is easy to discriminate).



    Then compute the distances to that plane.






    share|cite|improve this answer









    $endgroup$


















      -1












      $begingroup$

      There don't seem to be outliers, you can use a total-least-squares plane fitting (it gives three solutions but the true one is easy to discriminate).



      Then compute the distances to that plane.






      share|cite|improve this answer









      $endgroup$
















        -1












        -1








        -1





        $begingroup$

        There don't seem to be outliers, you can use a total-least-squares plane fitting (it gives three solutions but the true one is easy to discriminate).



        Then compute the distances to that plane.






        share|cite|improve this answer









        $endgroup$



        There don't seem to be outliers, you can use a total-least-squares plane fitting (it gives three solutions but the true one is easy to discriminate).



        Then compute the distances to that plane.







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Dec 7 '18 at 14:25









        Yves DaoustYves Daoust

        129k676227




        129k676227






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Mathematics Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3028869%2fdetermining-whether-a-large-series-of-3d-points-all-line-on-a-plane%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

            ComboBox Display Member on multiple fields

            Is it possible to collect Nectar points via Trainline?