/*-
 * Copyright (c) 1999,2000 Qube Software, Ltd.
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * 1. Redistributions of the source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 
 * 2. Any redistribution solely in binary form must conspicuously
 *    reproduce the following disclaimer in documentation provided with the
 *    binary redistribution.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'', WITHOUT ANY WARRANTIES, EXPRESS
 * OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  LICENSOR SHALL
 * NOT BE LIABLE FOR ANY LOSS OR DAMAGES RESULTING FROM THE USE OF THIS
 * SOFTWARE, EITHER ALONE OR IN COMBINATION WITH ANY OTHER SOFTWARE.
 * 
 * 	$Id: sphere3.h,v 1.3 2000/04/20 16:21:58 n_hibma Exp $
 */

#ifndef __sphere3_h__
#define __sphere3_h__

MATHS_BEGIN

struct Rayf;
struct Cylinder3f;

struct EXPORT_QMATHS Sphere3f
{
    Vec3f	position;
    float       radius;

    // Constructors
    Sphere3f()
    {
    }

    Sphere3f(const Box3f);
    Sphere3f(const Vec3f& p, float r)
	: position(p), radius(r)
    {
    }
    
    // Accessors
    Box3f               box() const;

    // Modifiers
    void		intersect(const Box3f&);
    bool                add(const Vec3f& v);
    void                add(const Sphere3f& s);

    // Testing
    bool		operator==(const Sphere3f& s) const
    {
	return position == s.position && radius == s.radius;
    }
    bool		equal(const Sphere3f&, float e = Epsilon) const;
    bool		contains(const Sphere3f&) const;
    bool		contains(const Vec3f&) const;
    bool		contains(const Box3f&) const;
    bool		contains(const Cylinder3f&) const;
    bool		intersects(const Sphere3f&) const;
    bool		intersects(const Rayf&, float&, float&) const;
    bool                intersects(const Vec3f* tri) const;

    // Features
    // Matrix operations
    Sphere3f		transform(const Matrix4f& m) const;
    Sphere3f		inverseTransform(const Matrix4f& m) const;
};

MATHS_END

#endif

