Remove Kilogram and Time classes
git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@370 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
62d6a44e24
commit
fa8abdb708
|
@ -1,51 +0,0 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2009 Daniel Chappuis *
|
||||
****************************************************************************
|
||||
* This file is part of ReactPhysics3D. *
|
||||
* *
|
||||
* ReactPhysics3D is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as published *
|
||||
* by the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* ReactPhysics3D is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public License *
|
||||
* along with ReactPhysics3D. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
// Libraries
|
||||
#include "Time.h"
|
||||
|
||||
// We want to use the ReactPhysics3D namespace
|
||||
using namespace reactphysics3d;
|
||||
|
||||
// Constructor
|
||||
Time::Time() {
|
||||
value = 0.0;
|
||||
}
|
||||
|
||||
// Constructor with arguments
|
||||
Time::Time(double value) throw(std::invalid_argument) {
|
||||
// Check if the value is positive
|
||||
if (value >= 0.0) {
|
||||
this->value = value;
|
||||
}
|
||||
else {
|
||||
// We throw an exception
|
||||
throw std::invalid_argument("Exception in Time : Wrong argument, a time value has to be positive");
|
||||
}
|
||||
}
|
||||
|
||||
// Copy-constructor
|
||||
Time::Time(const Time& time) {
|
||||
this->value = time.value;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Time::~Time() {
|
||||
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2009 Daniel Chappuis *
|
||||
****************************************************************************
|
||||
* This file is part of ReactPhysics3D. *
|
||||
* *
|
||||
* ReactPhysics3D is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as published *
|
||||
* by the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* ReactPhysics3D is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public License *
|
||||
* along with ReactPhysics3D. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef TIME_H
|
||||
#define TIME_H
|
||||
|
||||
// Libraries
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
// Namespace ReactPhysics3D
|
||||
namespace reactphysics3d {
|
||||
|
||||
/* -------------------------------------------------------------------
|
||||
Class Time :
|
||||
The Time class represents a time unity. The value inside is the
|
||||
time value in seconds.
|
||||
-------------------------------------------------------------------
|
||||
*/
|
||||
class Time {
|
||||
private :
|
||||
long double value; // Time in seconds
|
||||
|
||||
public :
|
||||
Time(); // Constructor
|
||||
Time(double value) throw(std::invalid_argument); // Constructor with arguments
|
||||
Time(const Time& time); // Copy-constructor
|
||||
virtual ~Time(); // Destructor
|
||||
|
||||
double getValue() const; // Return the time value in seconds
|
||||
void setValue(double value) throw(std::invalid_argument) ; // Set the time value
|
||||
|
||||
// Overloaded operators
|
||||
Time operator+(const Time& time2) const; // Overloaded operator for addition with Time
|
||||
Time operator-(const Time& time2) const throw(std::invalid_argument); // Overloaded operator for substraction with Time
|
||||
Time operator*(double number) const throw(std::invalid_argument); // Overloaded operator for multiplication with a number
|
||||
bool operator<(const Time& time2) const; // Overloaded operator for less than comparison
|
||||
bool operator<=(const Time& time2) const; // Overloaded operator for less than or equal comparison
|
||||
bool operator>(const Time& time2) const; // Overloaded operator for greater than comparison
|
||||
};
|
||||
|
||||
// --- Inlines functions --- //
|
||||
|
||||
// Return the value in seconds
|
||||
inline double Time::getValue() const {
|
||||
return value;
|
||||
}
|
||||
|
||||
// Set the value in seconds
|
||||
inline void Time::setValue(double value) throw(std::invalid_argument) {
|
||||
|
||||
// Check if the time value is positive
|
||||
if (value >= 0.0) {
|
||||
this->value = value;
|
||||
}
|
||||
else {
|
||||
// We throw an exception
|
||||
throw std::invalid_argument("Exception in test Time: Wrong argument, a time value has to be positive");
|
||||
}
|
||||
}
|
||||
|
||||
// Overloaded operator for addition with Time
|
||||
inline Time Time::operator+(const Time& time2) const {
|
||||
return Time(value + time2.value);
|
||||
}
|
||||
|
||||
// Overloaded operator for substraction with Time
|
||||
inline Time Time::operator-(const Time& time2) const throw(std::invalid_argument) {
|
||||
// Compute the result of the substraction
|
||||
double result = value - time2.value;
|
||||
|
||||
// If the result is negative
|
||||
if (result <= 0.0) {
|
||||
// We throw an exception
|
||||
throw std::invalid_argument("Exception in Time::operator- : The result should be positive");
|
||||
}
|
||||
|
||||
// Return the result
|
||||
return Time(result);
|
||||
}
|
||||
|
||||
// Overloaded operator for multiplication with a number
|
||||
inline Time Time::operator*(double number) const throw(std::invalid_argument) {
|
||||
// Check if the number is positive
|
||||
if (number > 0.0) {
|
||||
return Time(value*number);
|
||||
}
|
||||
else {
|
||||
// We throw an exception
|
||||
throw std::invalid_argument("Exception in Time::operator* : The argument number has to be positive");
|
||||
}
|
||||
}
|
||||
|
||||
// Overloaded operator for less than comparison
|
||||
inline bool Time::operator<(const Time& time2) const {
|
||||
return (getValue() < time2.getValue());
|
||||
}
|
||||
|
||||
// Overloaded operator for less than or equal comparison
|
||||
inline bool Time::operator<=(const Time& time2) const {
|
||||
return (getValue() <= time2.getValue());
|
||||
}
|
||||
|
||||
// Overloaded operator for greater than comparison
|
||||
inline bool Time::operator>(const Time& time2) const {
|
||||
return (getValue() > time2.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,26 +0,0 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2009 Daniel Chappuis *
|
||||
****************************************************************************
|
||||
* This file is part of ReactPhysics3D. *
|
||||
* *
|
||||
* ReactPhysics3D is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as published *
|
||||
* by the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* ReactPhysics3D is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public License *
|
||||
* along with ReactPhysics3D. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef PHYSICS_H
|
||||
#define PHYSICS_H
|
||||
|
||||
// Libraries
|
||||
#include "Time.h"
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user