не волнуйся, я точно понимаю, что ты чувствуешь. Я предполагаю, что вам нужны фрагменты кода. так что вы можете реализовать это по-своему. вам нужно проделать намного больше работы, чем просто найти точечный продукт.
Вы должны понять этот алгоритм и внедрить его в свою собственную программу.
то, что я сделаю, это даст вам реализацию этого алгоритма
расстояние со знаком между точкой и плоскостью
Вот несколько примеров реализации этих алгоритмов на языке C ++.
// Assume that classes are already given for the objects:
// Point and Vector with
// coordinates {float x, y, z;}
// operators for:
// Point = Point ± Vector
// Vector = Point - Point
// Vector = Scalar * Vector (scalar product)
// Plane with a point and a normal {Point V0; Vector n;}
//===================================================================
// dot product (3D) which allows vector operations in arguments
#define dot(u,v) ((u).x * (v).x + (u).y * (v).y + (u).z * (v).z)
#define norm(v) sqrt(dot(v,v)) // norm = length of vector
#define d(u,v) norm(u-v) // distance = norm of difference
// pbase_Plane(): get base of perpendicular from point to a plane
// Input: P = a 3D point
// PL = a plane with point V0 and normal n
// Output: *B = base point on PL of perpendicular from P
// Return: the distance from P to the plane PL
float
pbase_Plane( Point P, Plane PL, Point* B)
{
float sb, sn, sd;
sn = -dot( PL.n, (P - PL.V0));
sd = dot(PL.n, PL.n);
sb = sn / sd;
*B = P + sb * PL.n;
return d(P, *B);
}
взято отсюда:
http://www.softsurfer.com/Archive/algorithm_0104/algorithm_0104.htm
PK