Example #1
0
void
plane::
extendBy ( const sphere& sphereIn )
{
	if ( !sphereIn.isEmpty() )
	{
		vec3 pos ( math::vec3::NoInit );
		ValueType radius;
		sphereIn.get ( pos, radius );
		vec3 dir = normal;
		dir.normalize ();
		vec3 pt = pos + dir * radius;
		extendBy ( pt );
		pt = pos - dir * radius;
		extendBy ( pt );
	}
}
Example #2
0
void
sphere::
extendBy ( const sphere& sphere )
{
	if ( this == &sphere )
		return;					// no extend by self.

	if ( sphere.isEmpty () )
		return;					// do nothing with empty spheres

	if ( isEmpty () )
	{
		*this = sphere;
	}
	else
	{
      // this finds the vector seperating this and sphere and add to
      // the length the radius of the other sphere to get a point on
      // the far side of sphere... it then calls extendBy with the
      // calculated point

		vec3 diff ( sphere.center );
		diff -= center;

		ValueType diffLen = diff.length ();

		diff /= diffLen;

		diffLen += sphere.radius;

		diff *= diffLen;

		diff += center;

		extendBy ( diff );
	}
}