Version 4.4.0

This commit is contained in:
Gary Scavone
2013-09-29 23:11:39 +02:00
committed by Stephen Sinclair
parent d199342e86
commit eccd8c9981
287 changed files with 11712 additions and 7676 deletions

View File

@@ -1,3 +1,11 @@
#ifndef STK_SPHERE_H
#define STK_SPHERE_H
#include "Stk.h"
#include "Vector3D.h"
namespace stk {
/***************************************************/
/*! \class Sphere
\brief STK sphere class.
@@ -5,60 +13,51 @@
This class implements a spherical ball with
radius, mass, position, and velocity parameters.
by Perry R. Cook, 1995 - 2004.
by Perry R. Cook, 1995 - 2009.
*/
/***************************************************/
#ifndef STK_SPHERE_H
#define STK_SPHERE_H
#include "Stk.h"
#include "Vector3D.h"
class Sphere : public Stk
{
public:
//! Constructor taking an initial radius value.
Sphere(StkFloat radius = 1.0 );
//! Class destructor.
~Sphere();
Sphere( StkFloat radius = 1.0 ) { radius_ = radius; mass_ = 1.0; };
//! Set the 3D center position of the sphere.
void setPosition(StkFloat x, StkFloat y, StkFloat z);
void setPosition( StkFloat x, StkFloat y, StkFloat z ) { position_.setXYZ(x, y, z); };
//! Set the 3D velocity of the sphere.
void setVelocity(StkFloat x, StkFloat y, StkFloat z);
void setVelocity( StkFloat x, StkFloat y, StkFloat z ) { velocity_.setXYZ(x, y, z); };
//! Set the radius of the sphere.
void setRadius(StkFloat radius);
void setRadius( StkFloat radius ) { radius_ = radius; };
//! Set the mass of the sphere.
void setMass(StkFloat mass);
void setMass( StkFloat mass ) { mass_ = mass; };
//! Get the current position of the sphere as a 3D vector.
Vector3D* getPosition();
Vector3D* getPosition( void ) { return &position_; };
//! Get the relative position of the given point to the sphere as a 3D vector.
Vector3D* getRelativePosition(Vector3D *position);
Vector3D* getRelativePosition( Vector3D *position );
//! Set the velcoity of the sphere as a 3D vector.
StkFloat getVelocity(Vector3D* velocity);
StkFloat getVelocity( Vector3D* velocity );
//! Returns the distance from the sphere boundary to the given position (< 0 if inside).
StkFloat isInside(Vector3D *position);
StkFloat isInside( Vector3D *position );
//! Get the current sphere radius.
StkFloat getRadius();
StkFloat getRadius( void ) { return radius_; };
//! Get the current sphere mass.
StkFloat getMass();
StkFloat getMass( void ) { return mass_; };
//! Increase the current sphere velocity by the given 3D components.
void addVelocity(StkFloat x, StkFloat y, StkFloat z);
void addVelocity( StkFloat x, StkFloat y, StkFloat z );
//! Move the sphere for the given time increment.
void tick(StkFloat timeIncrement);
void tick( StkFloat timeIncrement );
private:
Vector3D position_;
@@ -68,4 +67,13 @@ private:
StkFloat mass_;
};
inline void Sphere::tick( StkFloat timeIncrement )
{
position_.setX(position_.getX() + (timeIncrement * velocity_.getX()));
position_.setY(position_.getY() + (timeIncrement * velocity_.getY()));
position_.setZ(position_.getZ() + (timeIncrement * velocity_.getZ()));
};
} // stk namespace
#endif