V
V
vaselekk2021-10-14 20:07:03
JavaScript
vaselekk, 2021-10-14 20:07:03

What algorithm to use to find the equation of a surface with 3 points?

I use the "vertex coordinate factor decomposition" method to find the general (surface) equation in space (because Ax + By + Cz + D = 0) . here is the js code:

var a21 = (o2["verhina2"][0] - o2["verhina1"][0])
var a22 = (o2["verhina2"][1] - o2["verhina1"][1])
var a33 = (o2["verhina3"][2] - o2["verhina1"][2])
var a23 = (o2["verhina2"][2] - o2["verhina1"][2])
var a31 = (o2["verhina3"][0] - o2["verhina1"][0])
var a32 = (o2["verhina3"][1] - o2["verhina1"][1])

var A_plosha = (a22*a33 - a23*a32)
var B_plosha =(a23*a31 - a21*a33)
var C_plosha =  (a21*a32 - a22*a31)

var D_plosha = (A_plosha * (-1 * o2["verhina1"][0])) + (C_plosha * (-1 * o2["verhina1"][2])) + (B_plosha * (-1 * o2["verhina1"][1]))

Well, this method of determining the general surface equation is too inefficient (for tracing polygons), so: what is the best algorithm to use to find the general surface equation?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wataru, 2021-10-14
@vaselekk

Let the point p=(x,y,z) belong to the plane. Let 3 points - p1, p2, p3.
Then the vector (p-p1) must be decomposed into vectors p2-p1 and p3-p1.
Those. the determinant of the 3x3 matrix of these three vectors must be zero.

det {{x-p1x, p2x-p1x, p3x-p1x},
 {y-p1y, p2y-p1y, p3y-p1y},
 {z-p1z, p2z-p1z, p3z-p1z}} = 0

Expand the determinant in the first column and get
A = det({{p2y-p1y, p3y-p1y}, {p2z-p1z, p3z-p1z}})
Etc.
D = -p1x*A-p1y*B-p1z*C

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question