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
stk::Sphere::isInside
StkFloat isInside(Vector3D *position)
Returns the distance from the sphere boundary to the given position (< 0 if inside).
stk::Sphere::getRadius
StkFloat getRadius(void)
Get the current sphere radius.
Definition Sphere.h:51
stk::Sphere::setMass
void setMass(StkFloat mass)
Set the mass of the sphere.
Definition Sphere.h:36
stk::Sphere::addVelocity
void addVelocity(StkFloat x, StkFloat y, StkFloat z)
Increase the current sphere velocity by the given 3D components.
stk::Sphere::getVelocity
StkFloat getVelocity(Vector3D *velocity)
Set the velocity of the sphere as a 3D vector.
stk::Sphere::Sphere
Sphere(StkFloat radius=1.0)
Constructor taking an initial radius value.
Definition Sphere.h:24
stk::Sphere::getRelativePosition
Vector3D * getRelativePosition(Vector3D *position)
Get the relative position of the given point to the sphere as a 3D vector.
stk::Sphere::getPosition
Vector3D * getPosition(void)
Get the current position of the sphere as a 3D vector.
Definition Sphere.h:39
stk::Sphere::getMass
StkFloat getMass(void)
Get the current sphere mass.
Definition Sphere.h:54
stk::Sphere::setRadius
void setRadius(StkFloat radius)
Set the radius of the sphere.
Definition Sphere.h:33
stk::Sphere::setVelocity
void setVelocity(StkFloat x, StkFloat y, StkFloat z)
Set the 3D velocity of the sphere.
Definition Sphere.h:30
stk::Sphere::setPosition
void setPosition(StkFloat x, StkFloat y, StkFloat z)
Set the 3D center position of the sphere.
Definition Sphere.h:27
stk::Sphere::tick
void tick(StkFloat timeIncrement)
Move the sphere for the given time increment.
Definition Sphere.h:70
stk::Stk::Stk
Stk(void)
Default constructor.
stk::Vector3D
STK 3D vector class.
Definition Vector3D.h:20
stk::Vector3D::setX
void setX(StkFloat x)
Set the X value.
Definition Vector3D.h:42
stk
The STK namespace.
Definition ADSR.h:6

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