33 #define VERRY_SMALL 0.000001
35 #define TRIANLE_BACK_DIST 0.00001
36 #define TRIANGLE_SPACING 0.00000001
38 #define TRIANLE_BACK_DIST 0.00001
68 BOOL laTriangle3::isInsideVolume(laPoint3 &pt)
76 pln[0].
build(
p[1],
p[0], new_p[0]);
77 pln[1].
build(
p[2],
p[1], new_p[1]);
78 pln[2].
build(
p[0],
p[2], new_p[2]);
80 if( (pln[0].distance(pt)>0) &&
81 (pln[1].distance(pt)>0) &&
82 (pln[2].distance(pt)>0) )
89 void laTriangle3::wrapPoint(laPoint3 &p)
91 double len_xz = sqrt(p.x()*p.x() + p.z()*p.z());
92 double len_xy = sqrt(p.x()*p.x() + p.y()*p.y());
95 oz.x(0); oz.y(0); oz.z(1);
98 oz.x(0); oz.y(1); oz.z(0);
107 double ry = p_xz.angle(oz) + n_xz.angle(oz);
116 double rz = p_xy.angle(oy) + n_xy.angle(oy);
129 p[0] = sin(rz)*len_xy;
130 p[1] = cos(rz)*len_xy;
151 #define PUSH_LINE(a, b) { arv[vcnt] = b - a; vcnt++; }
158 laPoint3 laTriangle3::collide(
laTriangle3 &t, laPoint3 &vt)
167 unsigned i, itri, imy;
170 laLine3 ar_tri_procet_lines[3];
176 laPoint3 v_norm_minus;
180 v_norm_minus = -1*v_norm_minus;
181 v_norm_minus = v_norm_minus/v_norm_minus.lenght();
184 v_minus = -1*v_minus;
187 laPoint3 b = this->p[0] + vt;
203 if((k>=0) && (k<=1))
if(isInsideVolume(p))
207 PUSH_LINE(t.
p[i], p);
222 if((k>=0) && (k<=1))
if(t.isInsideVolume(p))
226 PUSH_LINE(p, this->p[i]);
234 getPerimeterLines(ar_my_lines);
235 tri_proect.getPerimeterLines(ar_tri_procet_lines);
237 for(itri=0; itri<3; itri++)
239 p_ln_pro_tri = ar_tri_procet_lines+itri;
241 for(imy=0; imy<3; imy++)
243 p_ln_my = ar_my_lines+imy;
250 if((k1>=0) && (k1<=1))
if((k2>=0) && (k2<=1))
267 for(i=0; i<vcnt; i++)
269 if(fabs(arv[i].x())<fabs(vok.x()))
271 vok[0] = arv[i].x() + v_norm_minus.x()*TRIANLE_BACK_DIST;
273 if(fabs(arv[i].y())<fabs(vok.y()))
275 vok[1] = arv[i].y() + v_norm_minus.y()*TRIANLE_BACK_DIST;
277 if(fabs(arv[i].z())<fabs(vok.z()))
279 vok[2] = arv[i].z() + v_norm_minus.z()*TRIANLE_BACK_DIST;
288 if( (r.lenght()>TRIANLE_BACK_DIST) )
291 laPoint3 b = r + this->p[0];
300 laPoint3 vresp = c - this->p[0];
laPoint3 intersection(laLine3 &l, double &pk1)
Find point of intersection (or nearest point) to another laLine3.
void build(laPoint3 &a, laPoint3 &b, laPoint3 &c)
Build laPlane3 from three points ( laPoint3 objects )
laPoint3 normal
Normal vector.
void build_vec(laPoint3 &a, laPoint3 &v)
Build from an end-poind and vector.
laPoint3 p[3]
Vertices of the triangle.
laPlane3 pn
Parametric 3D plane.
3D triangle face NOTE: This class has not been tested (NT)
double distance(laPoint3 &p)
Find the shortest distance between a point and the plane.