4
$\begingroup$

I need help constructing a plane function, $z = f(x,y)$ that goes through three points, (05, 22, 20). (89, 0, 89) and (-1, -1, 10). I have tried to input it, but I dont know how.

enter image description here

$\endgroup$
2
  • 2
    $\begingroup$ The error message you got from Solve[] already tells you that () is not to be used that way. Replace those with {},and add the variables you want to solve for as the second argument: Solve[{(* stuff *)}, {a, b, c}] $\endgroup$ Commented Feb 1, 2021 at 13:21
  • $\begingroup$ A related question. $\endgroup$ Commented Feb 2, 2021 at 8:40

4 Answers 4

3
$\begingroup$
ClearAll[lazyMansPointsToPlaneFunction]
lazyMansPointsToPlaneFunction[pts_][x_, y_] := #2 & @@ 
    Reduce[RegionMember[InfinitePlane@pts][{x, y, z}], z, Reals]

Examples:

points = {{5, 22, 20}, {88, 0, 88}, {-1, -1, 10}}; 

lazyMansPointsToPlaneFunction[points][x, y]
 22616/2041 + (1784 x)/2041 + (422 y)/2041
Show[Plot3D[lazyMansPointsToPlaneFunction[points][x, y], {x, -10, 100}, {y, -10, 30}, 
   Mesh -> None, PlotStyle -> Opacity[.5, Yellow], 
   BoundaryStyle -> Directive[Thick, Red], BoxRatios -> Automatic], 
 Graphics3D[{{RandomColor[], Sphere[#, 2]} & /@ points}]]

enter image description here

SeedRandom[12345]
With[{points = RandomReal[50, {3, 3}]}, 
 Show[Plot3D[lazyMansPointsToPlaneFunction[points][x, y], {x, 0, 50}, {y, 0, 50}, 
   Mesh -> None, PlotStyle -> Opacity[.5, Yellow], 
   BoundaryStyle -> Directive[Thick, Red], BoxRatios -> Automatic], 
  Graphics3D[{{RandomColor[], Sphere[#, 2]} & /@ points}],  
  ImageSize -> Large]]

enter image description here

$\endgroup$
3
$\begingroup$
LinearModelFit[{{5, 22, 20}, {88, 0, 88}, {-1, -1, 10}}, {x, y}, {x, y}]

enter image description here

$\endgroup$
3
$\begingroup$

According to analytic geometry,we can calculate the normal of plane by Cross or calculate the volume of the three points by Det

p1 = {5, 22, 20};
p2 = {89, 0, 89};
p3 = {-1, -1, 10};
Simplify[({x, y, z} - p3) . Cross[p1 - p3, p2 - p3] == 0]
Det[{{x, y, z} - p3, p2 - p3, p1 - p3}] == 0

22873 + 1807 x + 426 y == 2064 z

-22873 - 1807 x - 426 y + 2064 z == 0

We can verify the result by

22873 + 1807 x + 426 y == 2064 z /. 
    Thread[{x, y, z} -> #] & /@ {p1, p2, p3} // Simplify

{True, True, True}

$\endgroup$
1
$\begingroup$

This will get you the coefficient values:

sol = Solve[
 {5 a + 22 b + c == 20, 88 a + c == 88, -a - b + c == 10},
 {a, b, c}
]

(* Out: {{a -> 1784/2041, b -> 422/2041, c -> 22616/2041}} *)

You can then replace these values in your generic equation and solve for $z$:

Reduce[a x + b y + c == z /. First@sol, z]

(* Out:  z == 22616/2041 + (1784 x)/2041 + (422 y)/2041 *)

You might also represent the equation of a plane as a matrix determinant as explained e.g. in this answer to Verify that the equation of a plane is this determinant:

Reduce[
  Det[{{x, y, z, 1}, {5, 22, 20, 1}, {88, 0, 88, 1}, {-1, -1, 10, 1}}] == 0, 
  z
]

(* Out: z == 22616/2041 + (1784 x)/2041 + (422 y)/2041 *)

You can construct that matrix using:

points = {{5, 22, 20}, {88, 0, 88}, {-1, -1, 10}};
mat = PadRight[Prepend[points, {x, y, z}], {4, 4}, 1];
Det[mat] == 0
Reduce[Det[mat] == 0, z]

(* Out: 
22616 + 1784 x + 422 y - 2041 z == 0
z == 22616/2041 + (1784 x)/2041 + (422 y)/2041
*)
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.