140 double dot00 = v0.
Dot(v0);
141 double dot01 = v0.
Dot(v1);
142 double dot02 = v0.
Dot(v2);
143 double dot11 = v1.
Dot(v1);
144 double dot12 = v1.
Dot(v2);
147 double invDenom = 1.0 / (dot00 * dot11 - dot01 * dot01);
148 double u = (dot11 * dot02 - dot01 * dot12) * invDenom;
149 double v = (dot00 * dot12 - dot01 * dot02) * invDenom;
152 return (u >= 0) && (v >= 0) && (u + v <= 1);
161 return math::Vector3d::Normal(
162 Vector3d(this->pts[0][0], this->pts[0][1], this->pts[0][2]),
163 Vector3d(this->pts[1][0], this->pts[1][1], this->pts[1][2]),
164 Vector3d(this->pts[2][0], this->pts[2][1], this->pts[2][2]));
190 Vector3<T> dir = (_line[1] - _line[0]).Normalize();
192 double denom = norm.
Dot(
Vector3d(dir[0], dir[1], dir[2]));
195 if (!math::equal(denom, 0.0))
199 double intersection =
200 -norm.
Dot(
Vector3d(diff[0], diff[1], diff[2])) / denom;
203 if (intersection < 1.0 || intersection > _line.
Length())
207 _ipt1 = _line[0] + (dir * intersection);
215 if (this->Contains(_line))
221 else if (_line.
Intersect(this->Side(0), _ipt1))
226 else if (_line.
Intersect(this->Side(1), _ipt1))
231 else if (_line.
Intersect(this->Side(2), _ipt1))
252 double s = this->Perimeter() / 2.0;
253 T a = this->Side(0).Length();
254 T b = this->Side(1).Length();
255 T c = this->Side(2).Length();
259 return sqrt(s * (s-a) * (s-b) * (s-c));