template<class Real> Point3D<Real> RandomBallPoint (void) { Point3D < Real > p; while (1) { p.coords[0] = Real (1.0 - 2.0 * Random<Real> ()); p.coords[1] = Real (1.0 - 2.0 * Random<Real> ()); p.coords[2] = Real (1.0 - 2.0 * Random<Real> ()); double l = SquareLength (p); if (l <= 1) { return p; } } }
float Vector3f::Length() { return std::sqrt(SquareLength()); }
template<class Real> double Length (const Point3D<Real>& p) { return sqrt (SquareLength (p)); }