mirror of
https://github.com/thestk/stk
synced 2026-01-15 22:11:52 +00:00
Version 4.4.0
This commit is contained in:
committed by
Stephen Sinclair
parent
d199342e86
commit
eccd8c9981
@@ -5,49 +5,16 @@
|
||||
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.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#include "Sphere.h"
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
Sphere::Sphere(StkFloat radius)
|
||||
{
|
||||
radius_ = radius;
|
||||
mass_ = 1.0;
|
||||
};
|
||||
namespace stk {
|
||||
|
||||
Sphere::~Sphere()
|
||||
{
|
||||
}
|
||||
|
||||
void Sphere::setPosition(StkFloat x, StkFloat y, StkFloat z)
|
||||
{
|
||||
position_.setXYZ(x, y, z);
|
||||
};
|
||||
|
||||
void Sphere::setVelocity(StkFloat x, StkFloat y, StkFloat z)
|
||||
{
|
||||
velocity_.setXYZ(x, y, z);
|
||||
};
|
||||
|
||||
void Sphere::setRadius(StkFloat radius)
|
||||
{
|
||||
radius_ = radius;
|
||||
};
|
||||
|
||||
void Sphere::setMass(StkFloat mass)
|
||||
{
|
||||
mass_ = mass;
|
||||
};
|
||||
|
||||
Vector3D* Sphere::getPosition()
|
||||
{
|
||||
return &position_;
|
||||
};
|
||||
|
||||
Vector3D* Sphere::getRelativePosition(Vector3D* position)
|
||||
Vector3D* Sphere::getRelativePosition( Vector3D* position )
|
||||
{
|
||||
workingVector_.setXYZ(position->getX() - position_.getX(),
|
||||
position->getY() - position_.getY(),
|
||||
@@ -55,13 +22,13 @@ Vector3D* Sphere::getRelativePosition(Vector3D* position)
|
||||
return &workingVector_;
|
||||
};
|
||||
|
||||
StkFloat Sphere::getVelocity(Vector3D* velocity)
|
||||
StkFloat Sphere::getVelocity( Vector3D* velocity )
|
||||
{
|
||||
velocity->setXYZ( velocity_.getX(), velocity_.getY(), velocity_.getZ() );
|
||||
return velocity_.getLength();
|
||||
};
|
||||
|
||||
StkFloat Sphere::isInside(Vector3D *position)
|
||||
StkFloat Sphere::isInside( Vector3D *position )
|
||||
{
|
||||
// Return directed distance from aPosition to spherical boundary ( <
|
||||
// 0 if inside).
|
||||
@@ -73,16 +40,6 @@ StkFloat Sphere::isInside(Vector3D *position)
|
||||
return distance - radius_;
|
||||
};
|
||||
|
||||
StkFloat Sphere::getRadius()
|
||||
{
|
||||
return radius_;
|
||||
};
|
||||
|
||||
StkFloat Sphere::getMass()
|
||||
{
|
||||
return mass_;
|
||||
};
|
||||
|
||||
void Sphere::addVelocity(StkFloat x, StkFloat y, StkFloat z)
|
||||
{
|
||||
velocity_.setX(velocity_.getX() + x);
|
||||
@@ -90,10 +47,4 @@ void Sphere::addVelocity(StkFloat x, StkFloat y, StkFloat z)
|
||||
velocity_.setZ(velocity_.getZ() + z);
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user