The Synthesis ToolKit in C++ (STK)

Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

Sphere.h
1 #ifndef STK_SPHERE_H
2 #define STK_SPHERE_H
3
4 #include "Stk.h"
5 #include "Vector3D.h"
6
7 namespace stk {
8
9 /***************************************************/
18 /***************************************************/
19
20 class Sphere : public Stk
21 {
22 public:
24 Sphere( StkFloat radius = 1.0 ) { radius_ = radius; mass_ = 1.0; };
25
27 void setPosition( StkFloat x, StkFloat y, StkFloat z ) { position_.setXYZ(x, y, z); };
28
30 void setVelocity( StkFloat x, StkFloat y, StkFloat z ) { velocity_.setXYZ(x, y, z); };
31
33 void setRadius( StkFloat radius ) { radius_ = radius; };
34
36 void setMass( StkFloat mass ) { mass_ = mass; };
37
39 Vector3D* getPosition( void ) { return &position_; };
40
42 Vector3D* getRelativePosition( Vector3D *position );
43
45 StkFloat getVelocity( Vector3D* velocity );
46
48 StkFloat isInside( Vector3D *position );
49
51 StkFloat getRadius( void ) { return radius_; };
52
54 StkFloat getMass( void ) { return mass_; };
55
57 void addVelocity( StkFloat x, StkFloat y, StkFloat z );
58
60 void tick( StkFloat timeIncrement );
61
62 private:
63 Vector3D position_;
64 Vector3D velocity_;
65 Vector3D workingVector_;
66 StkFloat radius_;
67 StkFloat mass_;
68 };
69
70 inline void Sphere::tick( StkFloat timeIncrement )
71 {
72 position_.setX(position_.getX() + (timeIncrement * velocity_.getX()));
73 position_.setY(position_.getY() + (timeIncrement * velocity_.getY()));
74 position_.setZ(position_.getZ() + (timeIncrement * velocity_.getZ()));
75 };
76
77 } // stk namespace
78
79 #endif

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