non ti preoccupare, capisco esattamente come ti senti. Suppongo che tu voglia alcuni frammenti di codice. così puoi implementarlo nel tuo. devi fare molto più lavoro che trovare il prodotto punto.
Spetta a voi per capire questo algoritmo e implementarlo nel proprio programma di ciò che io voglio fare è dare un'implementazione di questo algoritmo
distanza firmato tra il punto e il piano
Ecco alcuni esempi di implementazioni "C++" di questi algoritmi.
// 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);
}
Tratto da qui: http://www.softsurfer.com/Archive/algorithm_0104/algorithm_0104.htm
PK
perché dist = dotProduct (dif, dif)? la distanza dovrebbe essere: d (P, * B); ?? – Pavan
d (p, b) chiama semplicemente questo = norma (sqrt (punto (p - b, p - b))); –
Quindi il mio codice fa la stessa cosa. –