POV-Ray : Newsgroups : povray.general : Plane passing through 3 points : Re: Plane passing through 3 points Server Time
29 Mar 2024 05:57:44 EDT (-0400)
  Re: Plane passing through 3 points  
From: Tor Olav Kristensen
Date: 1 May 2022 16:25:00
Message: <web.626eeb35e0a3ca27892957989db30a9@news.povray.org>
kurtz le pirate <kur### [at] gmailcom> wrote:
> Hello,
>
> I have 3 points A, B and C
> I would like the "plane" object to pass through these three points.
>
> It is easy to determine the equation of a plane that passes through
> these three points. We obtain this equation : ax + by + cz + d = 0
>
> I try to do : plane { <a, b, c>, d }
>
> but the plane does not pass through the points.
>
>
> Documentation at <http://www.povray.org/documentation/view/3.7.1/297/>
> indicates that the object "plane { <A, B, C>, D }" represent the plane
> defined by : A*x + B*y + C*z - D*sqrt(A^2 + B^2 + C^2) = 0
>
> ... I must be dumb but I can't make the link with my plan equation.
>
>
> A little help ?

Here's some code for you to experiment with:
NB:
I changed the names of your 3 points from A, B and C to pE, pF and pG,
so that those are not confused with the parameters A, B and C in the
plane equation that you quote from the documentation.

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.7;

global_settings { assumed_gamma 1.0 }

#include "colors.inc"

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare pE = <+3, -1, +7>;
#declare pF = <-2,  0, +5>;
#declare pG = <+1,  0, +9>;

sphere {
    pE, 0.1
    pigment { color Red }
}

sphere {
    pF, 0.1
    pigment { color Green }
}

sphere {
    pG, 0.1
    pigment { color Blue }
}


// Two vectors parallel to the plane
#declare vEF = pF - pE;
#declare vEG = pG - pE;


// Normalized normal vector to the plane
#declare vN = vnormalize(vcross(vEF, vEG));

// Distance from origin to the plane along the normal vector
#declare D = vdot(pE, vN);  // or vdot(pF, vN) or vdot(pG, vN)


/*
// This will also work

// Normal vector to the plane
#declare vN = vcross(vEF, vEG);

// Distance from origin to the plane along the normal vector
#declare D = vdot(pE, vnormalize(vN));
*/


plane {
    vN, D
    pigment { color Cyan }
}

/*
// Alternative way
plane {
    vcross(vEF, vEG), 0
    translate pE  // or translate pF or translate pG
    pigment { color Magenta }
}
*/

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

background { color Gray20 }

light_source {
    <-3, 3, -4>*100
    color White
}

camera {
    location -z
    right x
    up y
    direction z
    sky y
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

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