Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


Sphere.h

00001 #ifndef STK_SPHERE_H
00002 #define STK_SPHERE_H
00003 
00004 #include "Stk.h"
00005 #include "Vector3D.h"
00006 
00007 namespace stk {
00008 
00009 /***************************************************/
00018 /***************************************************/
00019 
00020 class Sphere : public Stk
00021 {
00022 public:
00024   Sphere( StkFloat radius = 1.0 ) { radius_ = radius; mass_ = 1.0; };
00025 
00027   void setPosition( StkFloat x, StkFloat y, StkFloat z ) { position_.setXYZ(x, y, z); };
00028 
00030   void setVelocity( StkFloat x, StkFloat y, StkFloat z ) { velocity_.setXYZ(x, y, z); };
00031 
00033   void setRadius( StkFloat radius ) { radius_ = radius; };
00034 
00036   void setMass( StkFloat mass ) { mass_ = mass; };
00037 
00039   Vector3D* getPosition( void ) { return &position_; };
00040 
00042   Vector3D* getRelativePosition( Vector3D *position );
00043 
00045   StkFloat getVelocity( Vector3D* velocity );
00046 
00048   StkFloat isInside( Vector3D *position );
00049 
00051   StkFloat getRadius( void ) { return radius_; };
00052 
00054   StkFloat getMass( void ) { return mass_; };
00055 
00057   void addVelocity( StkFloat x, StkFloat y, StkFloat z );
00058 
00060   void tick( StkFloat timeIncrement );
00061    
00062 private:
00063   Vector3D position_;
00064   Vector3D velocity_;
00065   Vector3D workingVector_;
00066   StkFloat radius_;
00067   StkFloat mass_;
00068 };
00069 
00070 inline void Sphere::tick( StkFloat timeIncrement )
00071 {
00072   position_.setX(position_.getX() + (timeIncrement * velocity_.getX()));
00073   position_.setY(position_.getY() + (timeIncrement * velocity_.getY()));
00074   position_.setZ(position_.getZ() + (timeIncrement * velocity_.getZ()));
00075 };
00076 
00077 } // stk namespace
00078 
00079 #endif

The Synthesis ToolKit in C++ (STK)
©1995-2012 Perry R. Cook and Gary P. Scavone. All Rights Reserved.