diff --git a/sources/demo/Camera.cpp b/sources/demo/Camera.cpp
deleted file mode 100644
index 4d9e6eec..00000000
--- a/sources/demo/Camera.cpp
+++ /dev/null
@@ -1,34 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-// Libraries
-#include "Camera.h"
-
-// Initialization of static variables
-double Camera::speed=0.5;
-
-// Constructor of the camera
-Camera::Camera() {
-
-}
-
-// Destructor of the camera
-Camera::~Camera() {
-
-}
diff --git a/sources/demo/Camera.h b/sources/demo/Camera.h
deleted file mode 100644
index 7ca15361..00000000
--- a/sources/demo/Camera.h
+++ /dev/null
@@ -1,91 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-#ifndef CAMERA_H
-#define CAMERA_H
-
-// Libraries
-#include "../reactphysics3d/reactphysics3d.h" // We want the mathematics stuff of reactphysics3d
-
-// Namespaces
-using namespace reactphysics3d;
-
-// Class Camera (abstract class)
-// In the project we will use two different camera. This is the superclass of the two
-// cameras. We will use a OutSideCamera that move arround the scene and an OnBoardCamera
-// that will simulate the deplacement of a viewer inside the scene
-class Camera {
- protected :
- Vector3D position; // Position of the camera
- Vector3D lookAtPoint; // Point where the camera is looking
- Vector3D viewVector; // Vector from the camera position to the view point
- static double speed; // Speed movement of the camera
-
- public :
- Camera(); // Constructor
- Camera(const Camera& camera); // Copy-constructor
- virtual ~Camera(); // Destructor
- virtual Vector3D getPosition() const; // Get the position of the camera
- virtual void setPosition(const Vector3D& pos); // Set the position of the camera
- virtual Vector3D getLookAtPoint() const; // Return the point where the camera is looking
- virtual Vector3D getViewVector() const; // Return the view vector of the camera
- virtual void updateViewVector()=0; // Update the view vector of the camera
- static void increaseSpeed(); // Increase the speed of camera movement
- static void decreaseSpeed(); // Decrease the speed of camera movement
-};
-
-// Get the position of the camera (inline function)
-inline Vector3D Camera::getPosition() const {
- // Return the position of the camera
- return position;
-}
-
-// Set the position of the camera (inline function)
-inline void Camera::setPosition(const Vector3D& pos) {
- // Set the position of the camera
- position = pos;
-}
-
-// Return the point where the camera is looking (inline function)
-inline Vector3D Camera::getLookAtPoint() const {
- return lookAtPoint;
-}
-
-// Return the view vector of the camera (inline function)
-inline Vector3D Camera::getViewVector() const {
- return viewVector;
-}
-
-// Increase the speed movement of the camera (inline function)
-inline void Camera::increaseSpeed()
-{
- speed= speed+0.05;
- if(speed>1)
- speed=1;
-}
-
-// Decrease the speep movement of the camera (inline function)
-inline void Camera::decreaseSpeed()
-{
- speed = speed-0.05;
- if(speed<=0)
- speed=0.005;
-}
-
-#endif
diff --git a/sources/demo/Context.cpp b/sources/demo/Context.cpp
deleted file mode 100755
index cefb64f9..00000000
--- a/sources/demo/Context.cpp
+++ /dev/null
@@ -1,76 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-// Libraries
-#include "Context.h"
-
-#include
-#include
-
-
-// Constructor of the class Context
-Context::Context() {
-
- // We add some objects in the context at the beginning ---> THESE THINGS WILL BE STORE IN A TEXT FILE
- Cube* cube1 = new Cube(Object::Position(-2.0, 1.0, -6.0), 2.0);
- Cube* cube2 = new Cube(Object::Position(0.0, 1.5, 6.0), 3.0);
- Cube* cube3 = new Cube(Object::Position(4.0, 4.0, -2.0), 2.0);
- Plane* plane1 = new Plane(Object::Position(0.0, 0.0, 0.0), 20.0, 30.0, Vector3D(-1.0, 0.0, 0.0), Vector3D(0.0, 0.0, 1.0));
-
- addObject(cube1);
- addObject(cube2);
- addObject(cube3);
- addObject(plane1);
-}
-
-
-// Destructor of the class Context
-Context::~Context() {
- // Delete all the objects in vectObjects
- for(int i=0; i . *
- ***************************************************************************/
-
-#ifndef CONTEXT_H
-#define CONTEXT_H
-
-// Libraries
-#include "Objects.h"
-
-#include
-
-// Class Context
-class Context {
- private :
- std::vector vectObjects; // Vector of Objects in the simulation
-
- public :
- Context(); // Constructor of the class
- ~Context(); // Destructor of the class
- int getNbObjects() const; // Return the number of objects in the context
- Object& getObject(int objectIndex) const; // Get an object from the context
- void addObject(Object* object); // Add an object into the context
- void removeObject(int objectIndex); // Remove an object from the context
-};
-
-// Method (inline) to get the number of objects in the context
-inline int Context::getNbObjects() const {
- return vectObjects.size();
-}
-
-#endif
diff --git a/sources/demo/Objects.cpp b/sources/demo/Objects.cpp
deleted file mode 100755
index a1b5b1b5..00000000
--- a/sources/demo/Objects.cpp
+++ /dev/null
@@ -1,123 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-// Libraries
-#include "Objects.h"
-
-//#include // To avoid an error due to the #include
-#include
-#include
-
-// ----- Class Object ----- //
-
-// Constructor of the class Object
-Object::Object(const Position& position) {
- this->position = position;
-}
-
-// Destructor of the class Object
-Object::~Object() {
-
-}
-
-// ----- Structure Position ----- //
-
-// Constructor without arguments of the structure Position
-Object::Position::Position() {
- x = 0.0;
- y = 0.0;
- z = 0.0;
-}
-
-// Constructor of the structure Position
-Object::Position::Position(double x, double y, double z) {
- this->x = x;
- this->y = y;
- this->z = z;
-};
-
-// ----- Class Cube ----- //
-
-// Constructor of the class Cube
-Cube::Cube(const Position& position, float size)
- :Object(position) {
- this->size = size;
-}
-
-// Destructor of the classe Cube
-Cube::~Cube() {
-
-}
-
-// Method to draw the cube
-void Cube::draw() const {
- // Translation of the cube to its position
- glTranslatef(position.x, position.y, position.z);
-
- // Draw the cube
- glutSolidCube(size);
-}
-
-
-// ----- Class Plane ----- //
-
-// Constructor of the class Plane
-Plane::Plane(const Position& position, float width, float height, const Vector3D& d1, const Vector3D& d2)
- :Object(position) {
- this->width = width;
- this->height = height;
- this->d1 = d1;
- this->d2 = d2;
-
- // Compute the unit normal vector of the plane by a cross product
- normalVector = d1.crossProduct(d2).getUnit();
-}
-
-// Destructor of the class Plane
-Plane::~Plane() {
-
-}
-
-// Method used to draw the plane
-void Plane::draw() const {
- // Translation of the cube to its position
- glTranslatef(position.x, position.y, position.z);
-
- float halfWidth = width / 2.0;
- float halfHeight = height / 2.0;
-
- // Draw the plane
- glBegin(GL_POLYGON);
- glColor3f(1.0, 1.0, 1.0);
- glVertex3f(position.x + d1.getX() * halfWidth + d2.getX() * halfHeight , position.y + d1.getY() * halfWidth + d2.getY() * halfHeight
- , position.z + d1.getZ() * halfWidth + d2.getZ() * halfHeight);
- glNormal3f(normalVector.getX(), normalVector.getY(), normalVector.getZ());
- glVertex3f(position.x + d1.getX() * halfWidth - d2.getX() * halfHeight , position.y + d1.getY() * halfWidth - d2.getY() * halfHeight
- , position.z + d1.getZ() * halfWidth - d2.getZ() * halfHeight);
- glNormal3f(normalVector.getX(), normalVector.getY(), normalVector.getZ());
- glVertex3f(position.x - d1.getX() * halfWidth - d2.getX() * halfHeight , position.y - d1.getY() * halfWidth - d2.getY() * halfHeight
- , position.z - d1.getZ() * halfWidth - d2.getZ() * halfHeight);
- glNormal3f(normalVector.getX(), normalVector.getY(), normalVector.getZ());
- glVertex3f(position.x - d1.getX() * halfWidth + d2.getX() * halfHeight , position.y - d1.getY() * halfWidth + d2.getY() * halfHeight
- , position.z - d1.getZ() * halfWidth + d2.getZ() * halfHeight);
- glEnd();
-}
-
-
-
diff --git a/sources/demo/Objects.h b/sources/demo/Objects.h
deleted file mode 100755
index 5e68f769..00000000
--- a/sources/demo/Objects.h
+++ /dev/null
@@ -1,79 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-#ifndef OBJECTS_H
-#define OBJECTS_H
-
-// Libraries
-#include "../reactphysics3d/reactphysics3d.h"
-
-// Namespaces
-using namespace reactphysics3d;
-
-/*
- Here we define all the objects that can appear in the simulation like cube, sphere, plane, ...
-*/
-
-// ----- Class Object (abstract) ----- //
-// Represent an object of the simulation
-class Object {
- public :
- // Structure Object::Position
- struct Position {
- double x; // x coordinate
- double y; // y coordinate
- double z; // z coordinate
-
- // Methods
- Position(); // Constructor without arguments of the structure Position
- Position(double x, double y, double z); // Constructor of the structure Position
- } position; // Position of the object
- Object(const Position& position); // Constructor of the class Object
- virtual ~Object(); // Destructor of the class Object
- virtual void draw() const =0; // pure virtual method to draw the object
-};
-
-// ----- Class Cube ----- //
-// Represente a Cube in the simulation
-class Cube : public Object {
- private :
- float size; // Size of a side in the cube
-
- public :
- Cube(const Position& position, float size); // Constructor of the class cube
- virtual ~Cube(); // Destructor of the class cube
- virtual void draw() const; // Method to draw the cube
-};
-
-
-// ----- Class Plane ---- //
-// Represent a plane in the simulation
-class Plane : public Object {
- public :
- float width; // Width of the plane
- float height; // Height of the plane
- Vector3D d1; // Unit vector in the plane
- Vector3D d2; // Unit vector in the plane
- Vector3D normalVector; // Unit normal vector of the plane
- Plane(const Position& position, float width, float height, const Vector3D& d1, const Vector3D& d2); // Constructor of the class Plane
- virtual ~Plane(); // Destructor of the class Plane
- virtual void draw() const; // Method to draw the plane
-};
-
-#endif
diff --git a/sources/demo/OutSideCamera.cpp b/sources/demo/OutSideCamera.cpp
deleted file mode 100644
index b830c6ab..00000000
--- a/sources/demo/OutSideCamera.cpp
+++ /dev/null
@@ -1,115 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-// Libraries
-#include "OutSideCamera.h"
-#include
-
-// Constants
-const double PI = 3.141592;
-
-// Constructor
-OutSideCamera::OutSideCamera() {
-
- // Initialize the attributes
- heightFromFloor = 20.0;
- horizontalAngleRotation = 0;
- verticalAngleRotation = 45;
- distanceFromOrigin = 10.0;
- lookAtPoint.setAllValues(0.0, 0.0, 0.0);
-
- // Update the position of the camera
- updatePosition();
-
- // Update the view vector of the camera
- updateViewVector();
-}
-
-// Destructor
-OutSideCamera::~OutSideCamera() {
-
-}
-
-// Compute the new position of the camera
-void OutSideCamera::updatePosition() {
-
- // Compute the floor distance from origin
- double floorDistance = distanceFromOrigin * cos(PI/180.0 * verticalAngleRotation);
-
- // Update the position of the camera
- position.setAllValues(floorDistance*cos(PI/180.0 * horizontalAngleRotation), distanceFromOrigin*sin(PI/180*verticalAngleRotation),
- floorDistance*sin(PI/180.0 * horizontalAngleRotation));
-}
-
-// Set the camera rotation angle and update the position of the camera
-void OutSideCamera::modifyHorizontalAngleRotation(int screenDistance, float fps) {
-
- // Update the horizontal rotation angle of the camera
- horizontalAngleRotation = (horizontalAngleRotation + int(screenDistance * 60.0 / fps)) % 360;
-
- // Update the position and the view vector of the camera
- updatePosition();
- updateViewVector();
-}
-
-// Set the vertical camera rotation angle
-void OutSideCamera::modifyVerticalAngleRotation(int screenDistance, float fps) {
-
- // Update the vertical rotation angle of the camera
- verticalAngleRotation = verticalAngleRotation + (screenDistance * 60.0 / fps);
-
- // Vertical angle limits
- if (verticalAngleRotation > 89) {
- verticalAngleRotation = 89;
- }
- if (verticalAngleRotation < 1) {
- verticalAngleRotation = 1;
- }
-
- // Update the position and the view vector of the camera
- updatePosition();
- updateViewVector();
-}
-
-// Increase the distance from origine of the camera (used for the zoom)
-void OutSideCamera::increaseDistance(float fps) {
-
- // Increase the distance from origin
- distanceFromOrigin = distanceFromOrigin + (speed * 60 / fps);
-
- // Update the position and the view vector of the camera
- updatePosition();
- updateViewVector();
-}
-
-// Decrease the distance from origine of the camera (used for the zoom)
-void OutSideCamera::decreaseDistance(float fps) {
-
- // Decrease the distance from origin
- distanceFromOrigin = distanceFromOrigin - (speed * 60 / fps);
-
- // Limit condition
- if(distanceFromOrigin < 1) {
- distanceFromOrigin=1;
- }
-
- // Update the position and the view vector of the camera
- updatePosition();
- updateViewVector();
-}
diff --git a/sources/demo/OutSideCamera.h b/sources/demo/OutSideCamera.h
deleted file mode 100644
index b0a61027..00000000
--- a/sources/demo/OutSideCamera.h
+++ /dev/null
@@ -1,64 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-#ifndef OUTSIDE_CAMERA_H
-#define OUTSIDE_CAMERA_H
-
-// Libraries
-#include "Camera.h"
-
-// ---- Class OutSideCamera ----
-// This camera can be move everywhere around the scene to obtain a outside view of the house
-class OutSideCamera : public Camera {
- private :
- double heightFromFloor; // Height from the floor
- int horizontalAngleRotation; // Horizontal rotation angle (in degree)
- int verticalAngleRotation; // Vertical rotation angle (in degree)
- double distanceFromOrigin; // Distance of the camera from the origin (used to zoom)
-
- public :
- OutSideCamera(); // Constructor
- OutSideCamera(const OutSideCamera& camera); // Copy-constructor
- virtual ~OutSideCamera(); // Destructor
- void updatePosition(); // Compute the new position of the camera
- void updateViewVector(); // Update the view vector of the camera
- double getHeightFromFloor() const; // Get the height of the camera from the floor
- void setHeightFromFloor(double height); // Set the height of the camera from the floor
- void modifyHorizontalAngleRotation(int screenDistance, float fps); // Modify the horizontal camera rotation angle
- void modifyVerticalAngleRotation(int screenDistance, float fps); // Modify the vertical camera rotation angle
- void increaseDistance(float fps); // Increase the distance of the camera from the origin
- void decreaseDistance(float fps); // Decrease the distance of the camera from the origin
-};
-
-// Compute the new view vector of the camera (inline function)
-inline void OutSideCamera::updateViewVector() {
- viewVector = Vector3D(0.0, 0.0, 0.0) - position;
-}
-
-// Get the height of the camera from the floor (inline function)
-inline double OutSideCamera::getHeightFromFloor() const {
- return heightFromFloor;
-}
-
-// Set the height of the camera from the floor (inline function)
-inline void OutSideCamera::setHeightFromFloor(double height) {
- heightFromFloor = height;
-}
-
-#endif
diff --git a/sources/demo/ReactDemo.h b/sources/demo/ReactDemo.h
deleted file mode 100755
index dc5a56ea..00000000
--- a/sources/demo/ReactDemo.h
+++ /dev/null
@@ -1,27 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-#ifndef REACT_DEMO_H
-#define REACT_DEMO_H
-
-// Constants
-const int WINWIDTH = 640; // Width of the OpenGL windows
-const int WINHEIGHT = 480; // Height of the OpenGL windows
-
-#endif
diff --git a/sources/demo/Scene.cpp b/sources/demo/Scene.cpp
deleted file mode 100755
index 9e85d364..00000000
--- a/sources/demo/Scene.cpp
+++ /dev/null
@@ -1,118 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-// Librairies
-#include "Scene.h"
-#include "Objects.h"
-
-// Constructor of the class Scene
-Scene::Scene() {
- // Initialise the material specular color
- mat_specular[0] = 1.0;
- mat_specular[1] = 1.0;
- mat_specular[2] = 1.0;
- mat_specular[3] = 1.0;
-
- // Initialize the material shininess
- mat_shininess[0] = 50.0;
-
- // Initialise the light source position
- light_position[0] = 20.0;
- light_position[1] = 9.0;
- light_position[2] = 15.0;
- light_position[3] = 0.0;
-
- // Initialise the ambient color of the light
- ambient_color[0] = 1.0;
- ambient_color[1] = 1.0;
- ambient_color[2] = 1.0;
- ambient_color[3] = 0.7;
-
- // Initialise the diffuse light color
- white_light[0] = 1.0;
- white_light[1] = 1.0;
- white_light[2] = 1.0;
- white_light[3] = 1.0;
-}
-
-// Destructor of the class Scene
-Scene::~Scene() {
-
-}
-
-// Init method
-void Scene::init() {
- glClearColor(0.0, 0.0, 0.0, 0.0); // Select the color for the background
- glShadeModel(GL_SMOOTH);
- glClearDepth(1.0);
-
- // Lighting settings
- glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); // Specular color of the material
- glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); // Shininess of the material
- glLightfv(GL_LIGHT0, GL_POSITION, light_position); // Position of the light source
- glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color); // Ambient color of the light
- glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light); // Diffuse color of the light
- glLightfv(GL_LIGHT0, GL_SPECULAR, white_light); // Specular color of the light
-
- glEnable(GL_LIGHTING); // Activate the lighting
- glEnable(GL_LIGHT0); // Activate a light source
- glEnable(GL_DEPTH_TEST); // Activate the Depth buffer
- //glEnable(GL_CULL_FACE);
-}
-
-// Display method
-void Scene::display(const Context& context) const {
- glClearColor(0,0,0,0);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-
- // Define the position and the direction of the camera
- //gluLookAt(30,10,0,0,0,0,0,1,0);
- double x = outsideCamera.getPosition().getX();
- double y = outsideCamera.getPosition().getY();
- double z = outsideCamera.getPosition().getZ();
- gluLookAt(x,y,z,0,0,0,0,1,0);
-
- // Draw all objects in the context
- for(int i=0; i . *
- ***************************************************************************/
-
-#ifndef SCENE_H
-#define SCENE_H
-
-// Libraries
-#include "Context.h"
-#include "OutSideCamera.h"
-
-#include
-#include // Used only to draw cubes
-#include
-#include
-
-
-// Scene class
-class Scene {
- private :
- GLfloat mat_specular[4]; // Material specular light color
- GLfloat mat_shininess[1]; // Material shininess
- GLfloat light_position[4]; // Position of the light source
- GLfloat ambient_color[4]; // Ambient color of the light
- GLfloat white_light[4]; // White light color
- OutSideCamera outsideCamera; // OutSide camera (Camera that can move around the scene)
-
- public :
- Scene(); // constructor of the class
- ~Scene(); // Destructor of the class
- void init(); // Initialize the values of OpenGL
- void display(const Context& context) const; // display the scene
- void reshape(int width, int height); // Reshape the window
- OutSideCamera& getOutSideCamera() ; // Return a reference to the outside camera
- float getCameraAngle1() const; // Return the angle of the camera
- float getCameraAngle2() const; // Return the angle of the camera
- void setCameraAngle1(float angle); // Set the angle of the camera
- void setCameraAngle2(float angle); // Set the angle of the camera
-};
-
-// Return a reference to the camera
-inline OutSideCamera& Scene::getOutSideCamera() {
- return outsideCamera;
-}
-
-#endif
diff --git a/sources/demo/Simulation.cpp b/sources/demo/Simulation.cpp
deleted file mode 100755
index 76a2facc..00000000
--- a/sources/demo/Simulation.cpp
+++ /dev/null
@@ -1,117 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-// Libraries
-#include "Simulation.h"
-#include "ReactDemo.h"
-#include
-
-// Constructor of the class Simulation
-Simulation::Simulation() {
- simRunning = false;
- mouseButtonPressed = false;
- fps = 0.0;
-}
-
-// Destructor of the class Simulation
-Simulation::~Simulation() {
-
-}
-
-// Method to start the simulation
-void Simulation::start() {
- // Initialisation of the OpenGL settings for the scene
- scene.init();
-
- // Reshape the windows for the first time
- scene.reshape(WINWIDTH, WINHEIGHT);
-
- // Activation of the simulation
- simRunning = true;
-
- // Get the current time
- currentFrameTime = SDL_GetTicks();
-
- // Main loop of the simulation
- while(simRunning) {
- // Check if an SDL event occured and make the apropriate actions
- checkEvents();
-
- // Display the actual scene
- scene.display(context);
-
- // Compute the fps (framerate)
- computeFps();
-
- //std::cout << fps << std::endl;
- }
-}
-
-// This method checks if an events occur and call the apropriate method
-void Simulation::checkEvents() {
- SDL_Event event; // An SDL event
-
- // Zoom of the outside camera
- if (SDL_GetKeyState(NULL)[SDLK_UP]) {
- scene.getOutSideCamera().decreaseDistance(fps);
- }
- else if(SDL_GetKeyState(NULL)[SDLK_DOWN]) {
- scene.getOutSideCamera().increaseDistance(fps);
- }
-
- // Check in the stack of events
- while(SDL_PollEvent(&event)) {
- // Check an event
- switch(event.type) {
- // An QUIT event occur
- case SDL_QUIT: simRunning = false;
- break;
-
- // A keyboard key has been pushed
- case SDL_KEYDOWN: // The Esc key has been pushed then we end the simulation
- if (event.key.keysym.sym == SDLK_ESCAPE)
- simRunning = false;
- break;
-
- // The size of the windows changed then we reshape the windows
- case SDL_VIDEORESIZE: scene.reshape(event.resize.w, event.resize.h);
- break;
-
- // If the mouse moved
- case SDL_MOUSEMOTION: if (SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1)) {
- // Rotation of the outSideCamera
- // TODO : Problem here when we try to implement fps indepence (if we try to
- // replace 60 by the variable fps
- scene.getOutSideCamera().modifyHorizontalAngleRotation(event.motion.xrel, 30);
- scene.getOutSideCamera().modifyVerticalAngleRotation(event.motion.yrel, 30);
- }
- }
- }
-}
-
-// Compute the framerate (fps) of the application
-void Simulation::computeFps() {
- double lastFrameTime = currentFrameTime;
-
- // Get the current time
- currentFrameTime = SDL_GetTicks();
-
- // Compute the new framerate
- fps = 1000 / double(currentFrameTime - lastFrameTime);
-}
diff --git a/sources/demo/Simulation.h b/sources/demo/Simulation.h
deleted file mode 100755
index 2130620b..00000000
--- a/sources/demo/Simulation.h
+++ /dev/null
@@ -1,46 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-#ifndef SIMULATION_H
-#define SIMULATION_H
-
-// Librairies
-#include "Context.h"
-#include "Scene.h"
-
-// Class Simulation
-class Simulation {
- private :
- Scene scene; // Scene object for displaying the simulation
- Context context; // Context of the simulation
- bool simRunning; // True if the simulation is running and false otherwise
- bool mouseButtonPressed; // True if the left mouse button is pressed
- double currentFrameTime; // Current frame time
- double fps; // Framerate of the application
-
- void computeFps(); // Compute the framerate of the application
-
- public :
- Simulation(); // Constructor of the class
- ~Simulation(); // Destructor of the class
- void start(); // Start the simulation
- void checkEvents(); // Check if SDL events occured and make the apropriate actions
-};
-
-#endif
diff --git a/sources/demo/main.cpp b/sources/demo/main.cpp
deleted file mode 100755
index 16195677..00000000
--- a/sources/demo/main.cpp
+++ /dev/null
@@ -1,106 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-// Libraries
-#include "../reactphysics3d/reactphysics3d.h"
-#include "Simulation.h"
-#include "ReactDemo.h"
-
-#include
-#include
-
-
-// Prototypes
-int initSDL();
-
-// global variables
-SDL_Surface * pScreen; // Pointer to the SDL windows
-
-// Main function
-int main(int argc, char** argv) {
-
- if(initSDL() > 0) {
- // If initSDL return an error then we exit the program
- return EXIT_FAILURE;
- }
-
- // Initialize the glut library. We will use glut only to display shapes like cube or sphere
- glutInit(&argc, argv);
-
- // Create a Simulation object used to simulate a physic world
- Simulation simulation;
-
- // Start the simulation
- simulation.start();
-
- std::cerr << "Fin normale du programme" << std::endl;
-
- // To avoid warnings notifying that argc et argv aren't used
- (argc);
- (argv);
-
- return (EXIT_SUCCESS);
-
- return 0;
-}
-
-// Methode to initialise the SDL and the windows
-int initSDL() {
- // Initialisation of SDL
- if( SDL_Init(SDL_INIT_VIDEO) < 0) {
- std::cerr << "Echec SDL_Init : " << SDL_GetError() << std::endl;
- return 1;
- }
-
- // Select the method to exit
- atexit( SDL_Quit );
-
- // Active double buffer mode
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-
- // Select the Depth Buffer size
- SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16);
-
- // Activation of displaying in windows mode
- SDL_Surface* pScreen = SDL_SetVideoMode(WINWIDTH, WINHEIGHT, 32, SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_RESIZABLE | SDL_SWSURFACE);
-
- // Check that displaying is activated
- if( !pScreen ) {
- std::cerr << "Echec de creation de la fenetre en 640x480 : " << SDL_GetError() << std::endl;
- return 1;
- }
-
- // Define the window title and the window icon
- SDL_WM_SetCaption("React Demo 0.01", NULL);
-
- // Get the state of the Double Buffer parameter
- int nValue;
- if( SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &nValue) < 0) {
- std::cerr << "Echec de recuperation du parametre SDL_GL_DOUBLEBUFFER : " << SDL_GetError() << std::endl;
- return 1;
- }
-
- // Check that Double Buffer mode is activated
- if(nValue != 1) {
- std::cerr << "Erreur : SDL_GL_DOUBLEBUFFER inactif" << std::endl;
- return 1;
- }
-
- return 0;
-}
diff --git a/sources/reactphysics3d/mathematics/Matrix.cpp b/sources/reactphysics3d/mathematics/Matrix.cpp
deleted file mode 100644
index cf48744c..00000000
--- a/sources/reactphysics3d/mathematics/Matrix.cpp
+++ /dev/null
@@ -1,415 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-// Libraries
-#include
-#include "Matrix.h"
-
-// Namespaces
-using namespace reactphysics3d;
-
-// Constructor of the class Matrix
-Matrix::Matrix(int nbRow, int nbColumn) throw(std::invalid_argument)
- :nbRow(nbRow),nbColumn(nbColumn) {
- // Check the arguments
- if (nbRow>0 && nbColumn>0) {
-
- // Create the two dimensional dynamic array
- array = new double*[nbRow];
-
- assert(array != 0); // Array pointer musn't be null
-
- for(int i=0; iarray;
-}
-
-
-// Function that return the cofactor matrix by removing row i and column j
-Matrix Matrix::getCofactor(int i, int j) const throw(std::invalid_argument) {
- // If i and j are in the matrix
- if (0<= i && i < nbRow && 0<= j && j 0) {
- // Create a new matrix
- Matrix identityMatrix(dimension,dimension);
-
- // Fill in the identity matrix
- for(int i=0; igetValue(i,j) + matrix2.getValue(i,j));
- }
- }
-
- // Return the sum matrix
- return sumMatrix;
- }
- else {
- // We throw an MathematicsException
- throw MathematicsException("MathematicsException : Addition of the matrices isn't possible beacause the size of the matrices aren't the same");
- }
-}
-
-// Definition of the operator - for the substraction of two matrices with references
-Matrix Matrix::operator-(const Matrix& matrix2) const throw(MathematicsException) {
- if (nbRow == matrix2.nbRow && nbColumn == matrix2.nbColumn) {
- // Create a new matrix
- Matrix sumMatrix(nbRow, nbColumn);
-
- // Substract the two matrices
- for(int i=0; inbColumn; ++j) {
- sumMatrix.setValue(i, j, this->getValue(i,j) - matrix2.getValue(i,j));
- }
- }
-
- // Return the sum matrix
- return sumMatrix;
- }
- else {
- // We throw a MathematicsException
- throw MathematicsException("MathematicsException : Substraction of the matrices isn't possible beacause the size of the matrices aren't the same");
- }
-}
-
-// Overloaded operator * for the multiplication of the matrix with a number
-Matrix Matrix::operator*(double nb) const {
- // Creation of the result matrix
- Matrix result(nbRow,nbColumn);
-
- // Multiplication of the matrix with the number
- for(int i=0; isetValue(i,j, matrix2.getValue(i,j));
- }
- }
- }
-
- // Return a reference to the matrix
- return *this;
- }
- else {
- // Throw a MathematicsException
- throw MathematicsException("MathematicsException : Assignment impossible because the size of the matrices aren't the same !");
- }
-}
-
-// Overloaded operator for equality condition
-bool Matrix::operator==(const Matrix& matrix2) const throw(MathematicsException) {
- // Check if the matrices dimensions are compatible
- if (nbRow == matrix2.nbRow && nbColumn == matrix2.nbColumn) {
- for (int i=0; i . *
- ***************************************************************************/
-
-#ifndef MATRIX_H
-#define MATRIX_H
-
-// Libraries
-#include "exceptions.h"
-#include
-#include
-
-// ReactPhysics3D namespace
-namespace reactphysics3d {
-
-/* -------------------------------------------------------------------
- Class Matrix :
- This class represents a matrix.
- -------------------------------------------------------------------
-*/
-class Matrix {
- private :
- int nbRow; // Number of row in the matrix
- int nbColumn; // Number of colum in the matrix
- double** array; // Dynamic array that contains the values of the matrix
-
- public :
- Matrix(int nbRow, int nbColum) throw(std::invalid_argument); // Constructor of the class Matrix
- Matrix(const Matrix& matrix); // Copy constructor of the class Matrix
- virtual ~Matrix(); // Destructor of the class Matrix
- double getValue(int i, int j) const throw(std::invalid_argument); // Return a value in the matrix
- void setValue(int i, int j, double value) throw(std::invalid_argument); // Set a value in the matrix
- int getNbRow() const; // Return the number of row of the matrix
- int getNbColumn() const; // Return the number of column of the matrix
- Matrix getCofactor(int i, int j) const throw(std::invalid_argument); // Return the cofactor matrix by removing row i and column j
- Matrix getTranspose() const; // Return the transposed matrixs
- Matrix getInverse() const throw(MathematicsException); // Return the inverse of the matrix if there exists
- double getDeterminant() const throw(MathematicsException); // Return the determinant of the matrix
- double getTrace() const throw(MathematicsException); // Return the trace of a square matrix
- static Matrix identity(int dimension) throw(std::invalid_argument); // Return the identity matrix I of the given dimension
-
- void display() const; // TO DELETE
-
- // --- Overloaded operators --- //
- Matrix operator+(const Matrix& matrix2) const throw(MathematicsException); // Overloaded operator for addition
- Matrix operator-(const Matrix& matrix2) const throw(MathematicsException); // Overloaded operator for substraction
- Matrix operator*(double nb) const; // Overloaded operator for multiplication with a number
- Matrix operator*(const Matrix& matrix2) const throw(MathematicsException); // Overloaded operator for multiplication with a matrix
- Matrix& operator=(const Matrix& matrix2) throw(MathematicsException); // Overloaded operator for assignment
- bool operator==(const Matrix& matrix2) const throw(MathematicsException); // Overloaded operator for equality condition
-};
-
-// Function to get a value in the matrix (inline)
-inline double Matrix::getValue(int i, int j) const throw(std::invalid_argument) {
- if (0 <= i && i < nbRow && 0 <= j && j < nbColumn) {
- // get the value in the matrix
- return array[i][j];
- }
- else {
- // We Throw an out_of_range exception
- throw std::invalid_argument("Exception : The index i or j is outside the matrix size !");
- }
-}
-
-// Function to set a value in the matrix (inline)
-inline void Matrix::setValue(int i, int j, double value) throw(std::invalid_argument) {
- if (0 <= i && i < nbRow && 0 <= j && j < nbColumn) {
- // Set the value in the matrix
- this->array[i][j] = value;
- }
- else {
- // We Throw an out_of_range exception
- throw std::invalid_argument("Exception : The index i or j is outside the matrix size !");
- }
-}
-
-// Function that return the number of row of the matrix (inline)
-inline int Matrix::getNbRow() const {
- return nbRow;
-}
-
-// Function that return the number of colum of the matrix (inline)
-inline int Matrix::getNbColumn() const {
- return nbColumn;
-}
-
-// Overloaded operator for multiplication between a number and a Matrix (inline)
-inline Matrix operator*(double number, const Matrix& matrix) {
-
- // Return the result matrix
- return matrix * number;
-}
-
-} // End of the ReactPhysics3D namespace
-
-#endif
diff --git a/sources/reactphysics3d/mathematics/Matrix3x3.cpp b/sources/reactphysics3d/mathematics/Matrix3x3.cpp
deleted file mode 100644
index a2506c98..00000000
--- a/sources/reactphysics3d/mathematics/Matrix3x3.cpp
+++ /dev/null
@@ -1,219 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-// Libraries
-#include
-#include "Matrix3x3.h"
-
-// Namespaces
-using namespace reactphysics3d;
-
-// Constructor of the class Matrix3x3
-Matrix3x3::Matrix3x3() {
- // Initialize all values in the matrix to zero
- setAllValues(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
-}
-
-// Constructor with arguments
-Matrix3x3::Matrix3x3(double a1, double a2, double a3, double b1, double b2, double b3, double c1, double c2, double c3) {
- // Initialize the matrix with the values
- setAllValues(a1, a2, a3, b1, b2, b3, c1, c2, c3);
-}
-
-// Copy-constructor
-Matrix3x3::Matrix3x3(const Matrix3x3& matrix2) {
- // Copy the values in the matrix
- setAllValues(matrix2.array[0][0], matrix2.array[0][1], matrix2.array[0][2],
- matrix2.array[1][0], matrix2.array[1][1], matrix2.array[1][2],
- matrix2.array[2][0], matrix2.array[2][1], matrix2.array[2][2]);
-}
-
-// Create a Matrix3x3 from a quaternion (the quaternion can be non-unit)
-Matrix3x3::Matrix3x3(const Quaternion& quaternion) {
- double x = quaternion.getX();
- double y = quaternion.getY();
- double z = quaternion.getZ();
- double w = quaternion.getW();
-
- double nQ = x*x + y*y + z*z + w*w;
- double s = 0.0;
-
- if (nQ > 0.0) {
- s = 2.0/nQ;
- }
-
- // Computations used for optimization (less multiplications)
- double xs = x*s;
- double ys = y*s;
- double zs = z*s;
- double wxs = w*xs;
- double wys = w*ys;
- double wzs = w*zs;
- double xxs = x*xs;
- double xys = x*ys;
- double xzs = x*zs;
- double yys = y*ys;
- double yzs = y*zs;
- double zzs = z*zs;
-
- // Create the matrix corresponding to the quaternion
- setAllValues(1.0-yys-zzs, xys-wzs, xzs + wys,
- xys + wzs, 1.0-xxs-zzs, yzs-wxs,
- xzs-wys, yzs + wxs, 1.0-xxs-yys);
-}
-
-// Destructor
-Matrix3x3::~Matrix3x3() {
-
-}
-
-// Return the inverse matrix
-Matrix3x3 Matrix3x3::getInverse() const throw(MathematicsException) {
- // Compute the determinant of the matrix
- double determinant = getDeterminant();
-
- // Check if the determinant is equal to zero
- if (determinant != 0) {
- double invDeterminant = 1.0 / determinant;
- Matrix3x3 tempMatrix;
-
- // Compute the inverse of the matrix
- tempMatrix.setAllValues((array[1][1]*array[2][2]-array[2][1]*array[1][2]), -(array[1][0]*array[2][2]-array[2][0]*array[1][2]), (array[1][0]*array[2][1]-array[2][0]*array[1][1]),
- -(array[0][1]*array[2][2]-array[2][1]*array[0][2]), (array[0][0]*array[2][2]-array[2][0]*array[0][2]), -(array[0][0]*array[2][1]-array[2][0]*array[0][1]),
- (array[0][1]*array[1][2]-array[0][2]*array[1][1]), -(array[0][0]*array[1][2]-array[1][0]*array[0][2]), (array[0][0]*array[1][1]-array[0][1]*array[1][0]));
-
- // Return the inverse matrix
- return (invDeterminant * tempMatrix.getTranspose());
- }
- else {
- // Throw an exception because the inverse of the matrix doesn't exist if the determinant is equal to zero
- throw MathematicsException("MathematicsException : Impossible to compute the inverse of the matrix because the determinant is equal to zero");
- }
-}
-
-// Return the quaternion corresponding to the matrix (it returns a unit quaternion)
-Quaternion Matrix3x3::getQuaternion() const {
-
- // Get the trace of the matrix
- double trace = getTrace();
-
- double r;
- double s;
-
- if (trace < 0.0) {
- if (array[1][1] > array[0][0]) {
- if(array[2][2] > array[1][1]) {
- r = sqrt(array[2][2] - array[0][0] - array[1][1] + 1.0);
- s = 0.5 / r;
- return Quaternion((array[2][0] + array[0][2])*s, (array[1][2] + array[2][1])*s, 0.5*r, (array[1][0] - array[0][1])*s);
- }
- else {
- r = sqrt(array[1][1] - array[2][2] - array[0][0] + 1.0);
- s = 0.5 / r;
- return Quaternion((array[0][1] + array[1][0])*s, 0.5 * r, (array[1][2] + array[2][1])*s, (array[0][2] - array[2][0])*s);
- }
- }
- else if (array[2][2] > array[0][0]) {
- r = sqrt(array[2][2] - array[0][0] - array[1][1] + 1.0);
- s = 0.5 / r;
- return Quaternion((array[2][0] + array[0][2])*s, (array[1][2] + array[2][1])*s, 0.5 * r, (array[1][0] - array[0][1])*s);
- }
- else {
- r = sqrt(array[0][0] - array[1][1] - array[2][2] + 1.0);
- s = 0.5 / r;
- return Quaternion(0.5 * r, (array[0][1] + array[1][0])*s, (array[2][0] - array[0][2])*s, (array[2][1] - array[1][2])*s);
- }
- }
- else {
- r = sqrt(trace + 1.0);
- s = 0.5/r;
- return Quaternion((array[2][1]-array[1][2])*s, (array[0][2]-array[2][0])*s, (array[1][0]-array[0][1])*s, 0.5 * r);
- }
-}
-
-// Return the 3x3 identity matrix
-Matrix3x3 Matrix3x3::identity() {
- // Return the isdentity matrix
- return Matrix3x3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
-}
-
-// TO DELETE, THIS IS JUST FOR TESTING MATRICES
-void Matrix3x3::display() const {
- for(int i=0; i<3; ++i) {
- for(int j=0; j<3; ++j) {
- std::cout << array[i][j] << " ";
- }
-
- std::cout << std::endl;
- }
-}
-
-// Overloaded operator for addition
-Matrix3x3 Matrix3x3::operator+(const Matrix3x3& matrix2) const {
- // Return the sum matrix
- return Matrix3x3(array[0][0] + matrix2.array[0][0], array[0][1] + matrix2.array[0][1], array[0][2] + matrix2.array[0][2],
- array[1][0] + matrix2.array[1][0], array[1][1] + matrix2.array[1][1], array[1][2] + matrix2.array[1][2],
- array[2][0] + matrix2.array[2][0], array[2][1] + matrix2.array[2][1], array[2][2] + matrix2.array[2][2]);
-}
-
-// Overloaded operator for substraction
-Matrix3x3 Matrix3x3::operator-(const Matrix3x3& matrix2) const {
- // Return the substraction matrix
- return Matrix3x3(array[0][0] - matrix2.array[0][0], array[0][1] - matrix2.array[0][1], array[0][2] - matrix2.array[0][2],
- array[1][0] - matrix2.array[1][0], array[1][1] - matrix2.array[1][1], array[1][2] - matrix2.array[1][2],
- array[2][0] - matrix2.array[2][0], array[2][1] - matrix2.array[2][1], array[2][2] - matrix2.array[2][2]);
-}
-
-// Overloaded operator for multiplication with a number
-Matrix3x3 Matrix3x3::operator*(double nb) const {
- // Return multiplied matrix
- return Matrix3x3(array[0][0] * nb, array[0][1] * nb, array[0][2] * nb,
- array[1][0] * nb, array[1][1] * nb, array[1][2] * nb,
- array[2][0] * nb, array[2][1] * nb, array[2][2] * nb);
-}
-
-// Overloaded operator for multiplication with a matrix
-Matrix3x3 Matrix3x3::operator*(const Matrix3x3& matrix2) const {
- // Compute and return the multiplication of the matrices
- return Matrix3x3(array[0][0]*matrix2.array[0][0] + array[0][1]*matrix2.array[1][0] + array[0][2]*matrix2.array[2][0],
- array[0][0]*matrix2.array[0][1] + array[0][1]*matrix2.array[1][1] + array[0][2]*matrix2.array[2][1],
- array[0][0]*matrix2.array[0][2] + array[0][1]*matrix2.array[1][2] + array[0][2]*matrix2.array[2][2],
- array[1][0]*matrix2.array[0][0] + array[1][1]*matrix2.array[1][0] + array[1][2]*matrix2.array[2][0],
- array[1][0]*matrix2.array[0][1] + array[1][1]*matrix2.array[1][1] + array[1][2]*matrix2.array[2][1],
- array[1][0]*matrix2.array[0][2] + array[1][1]*matrix2.array[1][2] + array[1][2]*matrix2.array[2][2],
- array[2][0]*matrix2.array[0][0] + array[2][1]*matrix2.array[1][0] + array[2][2]*matrix2.array[2][0],
- array[2][0]*matrix2.array[0][1] + array[2][1]*matrix2.array[1][1] + array[2][2]*matrix2.array[2][1],
- array[2][0]*matrix2.array[0][2] + array[2][1]*matrix2.array[1][2] + array[2][2]*matrix2.array[2][2]);
-}
-
-// Overloaded operator for assignment
-Matrix3x3& Matrix3x3::operator=(const Matrix3x3& matrix2) {
- // Check for self-assignment
- if (this != &matrix2) {
- setAllValues(matrix2.array[0][0], matrix2.array[0][1], matrix2.array[0][2],
- matrix2.array[1][0], matrix2.array[1][1], matrix2.array[1][2],
- matrix2.array[2][0], matrix2.array[2][1], matrix2.array[2][2]);
- }
-
- // Return a reference to the matrix
- return *this;
-}
-
-
-
diff --git a/sources/reactphysics3d/mathematics/Matrix3x3.h b/sources/reactphysics3d/mathematics/Matrix3x3.h
deleted file mode 100644
index ede01190..00000000
--- a/sources/reactphysics3d/mathematics/Matrix3x3.h
+++ /dev/null
@@ -1,150 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-
-#ifndef MATRIX3X3_H
-#define MATRIX3X3_H
-
-// Libraries
-#include "exceptions.h"
-#include "Quaternion.h"
-
-// ReactPhysics3D namespace
-namespace reactphysics3d {
-
-
-/* -------------------------------------------------------------------
- Class Matrix3x3 :
- This class represents a 3x3 matrix.
- -------------------------------------------------------------------
-*/
-class Matrix3x3 {
- private :
- double array[3][3]; // Array with the values of the matrix
-
- public :
- Matrix3x3(); // Constructor of the class Matrix3x3
- Matrix3x3(double a1, double a2, double a3, double b1, double b2, double b3,
- double c1, double c2, double c3); // Constructor with arguments
- Matrix3x3(const Matrix3x3& matrix); // Copy-constructor
- Matrix3x3(const Quaternion& quaternion); // Create a Matrix3x3 from a Quaternion
- virtual ~Matrix3x3(); // Destructor
- double getValue(int i, int j) const throw(std::invalid_argument); // Get a value in the matrix
- void setValue(int i, int j, double value) throw(std::invalid_argument); // Set a value in the matrix
- void setAllValues(double a1, double a2, double a3, double b1, double b2, double b3,
- double c1, double c2, double c3); // Set all the values in the matrix
- Matrix3x3 getTranspose() const; // Return the transpose matrix
- double getDeterminant() const; // Return the determinant of the matrix
- double getTrace() const; // Return the trace of the matrix
- Matrix3x3 getInverse() const throw(MathematicsException); // Return the inverse matrix
- Quaternion getQuaternion() const; // Return the unit quaternion corresponding to the matrix
- static Matrix3x3 identity(); // Return the 3x3 identity matrix
-
- void display() const; // TO DELETE
-
- // --- Overloaded operators --- //
- Matrix3x3 operator+(const Matrix3x3& matrix2) const; // Overloaded operator for addition
- Matrix3x3 operator-(const Matrix3x3& matrix2) const ; // Overloaded operator for substraction
- Matrix3x3 operator*(double nb) const; // Overloaded operator for multiplication with a number
- Matrix3x3 operator*(const Matrix3x3& matrix2) const; // Overloaded operator for multiplication with a matrix
- Matrix3x3& operator=(const Matrix3x3& matrix2); // Overloaded operator for assignment
- bool operator==(const Matrix3x3& matrix2) const; // Overloaded operator for equality condition
-};
-
-
-// Method to get a value in the matrix (inline)
-inline double Matrix3x3::getValue(int i, int j) const throw(std::invalid_argument) {
- // Check the argument
- if (i>=0 && i<3 && j>=0 && j<3) {
- // Return the value
- return array[i][j];
- }
- else {
- // Throw an exception because of the wrong argument
- throw std::invalid_argument("Exception : The argument isn't in the bounds of the 3x3 matrix");
- }
-}
-
-// Method to set a value in the matrix (inline)
-inline void Matrix3x3::setValue(int i, int j, double value) throw(std::invalid_argument) {
- // Check the argument
- if (i>=0 && i<3 && j>=0 && j<3) {
- // Set the value
- array[i][j] = value;
- }
- else {
- // Throw an exception because of the wrong argument
- throw std::invalid_argument("Exception : The argument isn't in the bounds of the 3x3 matrix");
- }
-} // End of the dcmaths namespace
-
-// Method to set all the values in the matrix
-inline void Matrix3x3::setAllValues(double a1, double a2, double a3, double b1, double b2, double b3,
- double c1, double c2, double c3) {
- // Set all the values of the matrix
- array[0][0] = a1;
- array[0][1] = a2;
- array[0][2] = a3;
-
- array[1][0] = b1;
- array[1][1] = b2;
- array[1][2] = b3;
-
- array[2][0] = c1;
- array[2][1] = c2;
- array[2][2] = c3;
-}
-
-// Return the transpose matrix
-inline Matrix3x3 Matrix3x3::getTranspose() const {
- // Return the transpose matrix
- return Matrix3x3(array[0][0], array[1][0], array[2][0],
- array[0][1], array[1][1], array[2][1],
- array[0][2], array[1][2], array[2][2]);
-}
-
-// Return the determinant of the matrix
-inline double Matrix3x3::getDeterminant() const {
- // Compute and return the determinant of the matrix
- return (array[0][0]*(array[1][1]*array[2][2]-array[2][1]*array[1][2]) - array[0][1]*(array[1][0]*array[2][2]-array[2][0]*array[1][2]) +
- array[0][2]*(array[1][0]*array[2][1]-array[2][0]*array[1][1]));
-}
-
-// Return the trace of the matrix
-inline double Matrix3x3::getTrace() const {
- // Compute and return the trace
- return (array[0][0] + array[1][1] + array[2][2]);
-}
-
-// Overloaded operator for multiplication between a number and a Matrix3x3 (inline)
-inline Matrix3x3 operator*(double number, const Matrix3x3& matrix) {
- // Return the multiplied matrix
- return matrix * number;
-}
-
-// Overloaded operator for equality condition
-inline bool Matrix3x3::operator==(const Matrix3x3& matrix2) const {
- return (array[0][0] == matrix2.array[0][0] && array[0][1] == matrix2.array[0][1] && array[0][2] == matrix2.array[0][2] &&
- array[1][0] == matrix2.array[1][0] && array[1][1] == matrix2.array[1][1] && array[1][2] == matrix2.array[1][2] &&
- array[2][0] == matrix2.array[2][0] && array[2][1] == matrix2.array[2][1] && array[2][2] == matrix2.array[2][2]);
-}
-
-} // End of the ReactPhysics3D namespace
-
-#endif
diff --git a/sources/reactphysics3d/mathematics/Quaternion.cpp b/sources/reactphysics3d/mathematics/Quaternion.cpp
deleted file mode 100755
index 32453c90..00000000
--- a/sources/reactphysics3d/mathematics/Quaternion.cpp
+++ /dev/null
@@ -1,55 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-// Libraries
-#include "Quaternion.h"
-
-// Namespaces
-using namespace reactphysics3d;
-
-// Constructor of the class
-Quaternion::Quaternion()
- :x(0.0), y(0.0), z(0.0), w(0.0) {
-
-}
-
-// Constructor with arguments
-Quaternion::Quaternion(double x, double y, double z, double w)
- :x(x), y(y), z(z), w(w) {
-
-}
-
-// Constructor with the component w and the vector v=(x y z)
-Quaternion::Quaternion(double w, const Vector3D& v)
- :x(v.getX()), y(v.getY()), z(v.getZ()), w(w) {
-
-}
-
-// Copy-constructor
-Quaternion::Quaternion(const Quaternion& quaternion)
- :x(quaternion.x), y(quaternion.y), z(quaternion.z), w(quaternion.w) {
-
-}
-
-// Destructor
-Quaternion::~Quaternion() {
-
-}
-
-
diff --git a/sources/reactphysics3d/mathematics/Quaternion.h b/sources/reactphysics3d/mathematics/Quaternion.h
deleted file mode 100644
index 59cb96b0..00000000
--- a/sources/reactphysics3d/mathematics/Quaternion.h
+++ /dev/null
@@ -1,209 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-#ifndef QUATERNION_H
-#define QUATERNION_H
-
-// Libraries
-#include
-#include "Vector3D.h"
-#include "exceptions.h"
-
-// ReactPhysics3D namespace
-namespace reactphysics3d {
-
-/* -------------------------------------------------------------------
- Class Quaternion :
- This class represents a quaternion. We use the notation :
- q = (x*i, y*j, z*k, w) to represent a quaternion.
- -------------------------------------------------------------------
-*/
-class Quaternion
-{
- private :
- double x; // Component x of the quaternion
- double y; // Component y of the quaternion
- double z; // Component z of the quaternion
- double w; // Component w of the quaternion
-
- public :
- Quaternion(); // Constructor
- Quaternion(double x, double y, double z, double w); // Constructor with arguments
- Quaternion(double w, const Vector3D& v); // Constructor with the component w and the vector v=(x y z)
- Quaternion(const Quaternion& quaternion); // Copy-constructor
- ~Quaternion(); // Destructor
- double getX() const; // Return the component x of the quaternion
- double getY() const; // Return the component y of the quaternion
- double getZ() const; // Return the component z of the quaternion
- double getW() const; // Return the component w of the quaternion
- void setX(double x); // Set the value x
- void setY(double y); // Set the value y
- void setZ(double z); // Set the value z
- void setW(double w); // Set the value w
- Vector3D vectorV() const; // Return the vector v=(x y z) of the quaternion
- double length() const; // Return the length of the quaternion
- Quaternion getUnit() const throw (MathematicsException); // Return the unit quaternion
- Quaternion getConjugate() const; // Return the conjugate quaternion
- Quaternion getInverse() const throw (MathematicsException); // Return the inverse of the quaternion
-
- // --- Overloaded operators --- //
- Quaternion operator+(const Quaternion& quaternion) const; // Overloaded operator for the addition
- Quaternion operator-(const Quaternion& quaternion) const; // Overloaded operator for the substraction
- Quaternion operator*(double nb) const; // Overloaded operator for the multiplication with a constant
- Quaternion operator*(const Quaternion& quaternion) const; // Overloaded operator for the multiplication
- Quaternion& operator=(const Quaternion& quaternion); // Overloaded operator for assignment
- bool operator==(const Quaternion& quaternion) const; // Overloaded operator for equality condition
-};
-
-
-// Get the value x (inline)
-inline double Quaternion::getX() const {
- return x;
-}
-
-// Get the value y (inline)
-inline double Quaternion::getY() const {
- return y;
-}
-
-// Get the value z (inline)
-inline double Quaternion::getZ() const {
- return z;
-}
-
-// Get the value w (inline)
-inline double Quaternion::getW() const {
- return w;
-}
-
-// Set the value x (inline)
-inline void Quaternion::setX(double x) {
- this->x = x;
-}
-
-// Set the value y (inline)
-inline void Quaternion::setY(double y) {
- this->y = y;
-}
-
-// Set the value z (inline)
-inline void Quaternion::setZ(double z) {
- this->z = z;
-}
-
-// Set the value w (inline)
-inline void Quaternion::setW(double w) {
- this->w = w;
-}
-
-// Return the vector v=(x y z) of the quaternion
-inline Vector3D Quaternion::vectorV() const {
- // Return the vector v
- return Vector3D(x, y, z);
-}
-
-// Return the length of the quaternion (inline)
-inline double Quaternion::length() const {
- return sqrt(x*x + y*y + z*z + w*w);
-}
-
-// Return the unit quaternion
-inline Quaternion Quaternion::getUnit() const throw(MathematicsException) {
- double lengthQuaternion = length();
-
- // Check if the length is not equal to zero
- if (lengthQuaternion != 0.0) {
-
- // Compute and return the unit quaternion
- return Quaternion(x/lengthQuaternion, y/lengthQuaternion, z/lengthQuaternion, w/lengthQuaternion);
- }
- else {
- // Throw an exception because it's impossible to compute a unit quaternion if its length is equal to zero
- throw MathematicsException("MathematicsException : Impossible to compute the unit quaternion if the length of the quaternion is zero");
- }
-}
-
-// Return the conjugate of the quaternion (inline)
-inline Quaternion Quaternion::getConjugate() const {
- return Quaternion(-x, -y, -z, w);
-}
-
-// Return the inverse of the quaternion (inline)
-inline Quaternion Quaternion::getInverse() const throw(MathematicsException) {
- double lengthQuaternion = length();
- lengthQuaternion = lengthQuaternion * lengthQuaternion;
-
- // Check if the length is not equal to zero
- if (lengthQuaternion != 0.0) {
-
- // Compute and return the inverse quaternion
- return Quaternion(-x/lengthQuaternion, -y/lengthQuaternion, -z/lengthQuaternion, w/lengthQuaternion);
- }
- else {
- // Throw an exception because the inverse cannot be computed
- throw MathematicsException("MathematicsException : Impossible to compute the inverse of the quaternion because it's length is zero");
- }
-}
-
-// Overloaded operator for the addition of two quaternions
-inline Quaternion Quaternion::operator+(const Quaternion& quaternion) const {
- // Return the result quaternion
- return Quaternion(x + quaternion.x, y + quaternion.y, z + quaternion.z, w + quaternion.w);
-}
-
-// Overloaded operator for the substraction of two quaternions
-inline Quaternion Quaternion::operator-(const Quaternion& quaternion) const {
- // Return the result of the substraction
- return Quaternion(x-quaternion.x, y - quaternion.y, z - quaternion.z, w - quaternion.w);
-}
-
-// Overloaded operator for the multiplication with a constant
-inline Quaternion Quaternion::operator*(double nb) const {
- // Return the result
- return Quaternion(nb*x, nb*y, nb*z, nb*w);
-}
-
-// Overloaded operator for the multiplication of two quaternions
-inline Quaternion Quaternion::operator*(const Quaternion& quaternion) const {
- // Return the result of the multiplication
- return Quaternion(w*quaternion.w - vectorV().scalarProduct(quaternion.vectorV()), w*quaternion.vectorV()+quaternion.w*vectorV() + vectorV().crossProduct(quaternion.vectorV()));
-}
-
-// Overloaded operator for the assignment
-inline Quaternion& Quaternion::operator=(const Quaternion& quaternion) {
- // Check for self-assignment
- if (this != &quaternion) {
- x = quaternion.x;
- y = quaternion.y;
- z = quaternion.z;
- w = quaternion.w;
- }
-
- // Return this quaternion
- return *this;
-}
-
-// Overloaded operator for equality condition
-inline bool Quaternion::operator==(const Quaternion& quaternion) const {
- return (x == quaternion.x && y == quaternion.y && z == quaternion.z && w == quaternion.w);
-}
-
-} // End of the ReactPhysics3D namespace
-
-#endif
diff --git a/sources/reactphysics3d/mathematics/Vector.cpp b/sources/reactphysics3d/mathematics/Vector.cpp
deleted file mode 100755
index 017a34e5..00000000
--- a/sources/reactphysics3d/mathematics/Vector.cpp
+++ /dev/null
@@ -1,223 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-// Libraries
-#include "Vector.h"
-
-// Namespaces
-using namespace reactphysics3d;
-
-// Constructor of the class Vector
-Vector::Vector(int n) throw(std::invalid_argument) {
- // Check the argument
- if (n > 0) {
- // Create the array that contains the values of the vector
- nbComponent = n;
- tab = new double[nbComponent];
-
-
- // Fill the array with zero's value
- for(int i=0; i . *
- ***************************************************************************/
-
-#ifndef VECTOR_H
-#define VECTOR_H
-
-// Libraries
-#include "exceptions.h"
-#include
-#include
-
-// ReactPhysics3D namespace
-namespace reactphysics3d {
-
-/* -------------------------------------------------------------------
- Class Vector :
- This class represents a Vector.
- -------------------------------------------------------------------
-*/
-class Vector {
- private :
- double* tab; // Array of the vector's components
- int nbComponent; // number of components in the vector
-
- public :
- Vector(int n) throw(std::invalid_argument); // Constructor of the class Vector
- Vector(const Vector& vector); // Copy-constructor of the class Vector
- virtual ~Vector(); // Destructor of the class Vector
- double getValue(int n) const throw(std::invalid_argument); // Get a component of the vector
- void setValue(int n, double value) throw(std::invalid_argument); // Set the value of a component of the vector
- int getNbComponent() const; // Get the number of components in the vector
- double length() const; // Get the length of the vector
- Vector getUnit() const throw(MathematicsException); // Return the corresponding unit vector
- double scalarProduct(const Vector& vector) const throw(MathematicsException); // Scalar product of two vectors
- Vector crossProduct(const Vector& vector) const throw(MathematicsException); // Cross product of two vectors (in 3D only)
-
- // --- Overloaded operators --- //
- Vector operator+(const Vector& vector) const throw(MathematicsException); // Overloaded operator for addition
- Vector operator-(const Vector& vector) const throw(MathematicsException); // Overloaded operator for substraction
- Vector operator*(double number) const; // Overloaded operator for multiplication with a number
- Vector& operator=(const Vector& vector) throw(MathematicsException); // Overloaded operator for the assignement to a Vector
- bool operator==(const Vector& vector) const throw(MathematicsException); // Overloaded operator for the equality condition
-};
-
-
-// ------ Definition of inlines functions ------ //
-
-// Method to get the value of a component of the vector (inline)
-inline double Vector::getValue(int n) const throw(std::invalid_argument) {
- // Check the argument
- if (n>=0 && n= 0 && n . *
- ***************************************************************************/
-
-// Libraries
-#include "Vector3D.h"
-#include
-
-// Namespaces
-using namespace reactphysics3d;
-
-// Constructor of the class Vector3D
-Vector3D::Vector3D()
- :x(0.0), y(0.0), z(0.0) {
-
-}
-
-// Constructor with arguments
-Vector3D::Vector3D(double x, double y, double z)
- :x(x), y(y), z(z) {
-
-}
-
-// Copy-constructor
-Vector3D::Vector3D(const Vector3D& vector)
- :x(vector.x), y(vector.y), z(vector.z) {
-
-}
-
-// Destructor
-Vector3D::~Vector3D() {
-
-}
-
-// Return the corresponding unit vector
-Vector3D Vector3D::getUnit() const throw(MathematicsException) {
- double lengthVector = length();
-
- // Check if the length is equal to zero
- if (lengthVector != 0) {
- // Compute and return the unit vector
- double lengthInv = 1.0 / lengthVector;
- return Vector3D(x * lengthInv, y * lengthInv, z*lengthInv);
- }
- else {
- // Throw an exception because the length of the vector is zero
- throw MathematicsException("MathematicsException : Impossible to compute the unit vector because the length of the vector is zero");
- }
-}
-
-// Overloaded operator for addition
-Vector3D Vector3D::operator+(const Vector3D& vector) const {
- // Compute and return the sum of the two vectors
- return Vector3D(x + vector.x, y + vector.y, z + vector.z);
-}
-
-// Overloaded operator for substraction
-Vector3D Vector3D::operator-(const Vector3D& vector) const {
- // Compute and return the substraction of the two vectors
- return Vector3D(x - vector.x, y - vector.y, z - vector.z);
-}
-
-// Overloaded operator for multiplication with a number
-Vector3D Vector3D::operator*(double number) const {
- // Compute and return the result
- return Vector3D(x * number, y * number, z * number);
-}
-
-// Overloaded operator for the assignement to a Vector
-Vector3D& Vector3D::operator=(const Vector3D& vector) {
- // Check for self-assignment
- if (this != &vector) {
- // Copy the vector
- x = vector.x;
- y = vector.y;
- z = vector.z;
- }
-
- // Return a reference to the vector
- return *this;
-}
diff --git a/sources/reactphysics3d/mathematics/Vector3D.h b/sources/reactphysics3d/mathematics/Vector3D.h
deleted file mode 100755
index 99fbbb6c..00000000
--- a/sources/reactphysics3d/mathematics/Vector3D.h
+++ /dev/null
@@ -1,136 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-#ifndef VECTOR3D_H
-#define VECTOR3D_H
-
-// Libraries
-#include
-#include "exceptions.h"
-
-// ReactPhysics3D namespace
-namespace reactphysics3d {
-
-
-/* -------------------------------------------------------------------
- Class Vector3D :
- This classrepresents 3 dimensionnal vector in space.
- -------------------------------------------------------------------
-*/
-class Vector3D {
- private :
- double x; // X component of the vector
- double y; // Y component of the vector
- double z; // Z component of the vector
-
- public :
- Vector3D(); // Constructor of the class Vector3D
- Vector3D(double x, double y, double z); // Constructor with arguments
- Vector3D(const Vector3D& vector); // Copy-constructor
- virtual ~Vector3D(); // Destructor
- double getX() const; // Get the x component of the vector
- double getY() const; // Get the y component of the vector
- double getZ() const; // Get the z component of the vector
- void setX(double x); // Set the x component of the vector
- void setY(double y); // Set the y component of the vector
- void setZ(double z); // Set the z component of the vector
- void setAllValues(double x, double y, double z); // Set all the values of the vector
- double length() const; // Return the lenght of the vector
- Vector3D getUnit() const throw(MathematicsException); // Return the corresponding unit vector
- double scalarProduct(const Vector3D& vector) const; // Scalar product of two vectors
- Vector3D crossProduct(const Vector3D& vector) const; // Cross product of two vectors
-
- // --- Overloaded operators --- //
- Vector3D operator+(const Vector3D& vector) const; // Overloaded operator for addition
- Vector3D operator-(const Vector3D& vector) const ; // Overloaded operator for substraction
- Vector3D operator*(double number) const; // Overloaded operator for multiplication with a number
- Vector3D& operator=(const Vector3D& vector); // Overloaded operator for the assignement to a Vector
- bool operator==(const Vector3D& vector) const; // Overloaded operator for the equality condition
-};
-
-
-// Get the x component of the vector (inline)
-inline double Vector3D::getX() const {
- return x;
-}
-
-// Get the y component of the vector (inline)
-inline double Vector3D::getY() const {
- return y;
-}
-
-// Get the z component of the vector (inline)
-inline double Vector3D::getZ() const {
- return z;
-}
-
-// Set the x component of the vector (inline)
-inline void Vector3D::setX(double x) {
- this->x = x;
-}
-
-// Set the y component of the vector (inline)
-inline void Vector3D::setY(double y) {
- this->y = y;
-}
-
-// Set the z component of the vector (inline)
-inline void Vector3D::setZ(double z) {
- this->z = z;
-}
-
-// Set all the values of the vector (inline)
-inline void Vector3D::setAllValues(double x, double y, double z) {
- this->x = x;
- this->y = y;
- this->z = z;
-}
-
-// Return the length of the vector (inline)
-inline double Vector3D::length() const {
- // Compute and return the length of the vector
- return sqrt(x*x + y*y + z*z);
-}
-
-// Scalar product of two vectors (inline)
-inline double Vector3D::scalarProduct(const Vector3D& vector) const {
- // Compute and return the result of the scalar product
- return (x * vector.x + y * vector.y + z * vector.z);
-}
-
-// Cross product of two vectors (inline)
-inline Vector3D Vector3D::crossProduct(const Vector3D& vector) const {
- // Compute and return the cross product
- return Vector3D(y * vector.z - z * vector.y, z * vector.x - x * vector.z , x * vector.y - y * vector.x);
-}
-
-// Overloaded operator for multiplication between a number and a Vector3D (inline)
-inline Vector3D operator * (double number, const Vector3D& vector) {
- // Compute and return the result vector
- return vector * number;
-}
-
-// Overloaded operator for the equality condition
-inline bool Vector3D::operator == (const Vector3D& vector) const {
- return (x == vector.x && y == vector.y && z == vector.z);
-}
-
-} // End of the ReactPhysics3D namespace
-
-#endif
diff --git a/sources/reactphysics3d/mathematics/exceptions.cpp b/sources/reactphysics3d/mathematics/exceptions.cpp
deleted file mode 100755
index d72a9db3..00000000
--- a/sources/reactphysics3d/mathematics/exceptions.cpp
+++ /dev/null
@@ -1,58 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-// Libraries
-#include "exceptions.h"
-
-// Namespaces
-using namespace reactphysics3d;
-
-
-// Constructor of the MathematicsException class
-MathematicsException::MathematicsException(const std::string& msg)
- :std::runtime_error(msg) {
-
-}
-
-// Destructor of the MathException class
-MathematicsException::~MathematicsException() throw() {
-
-}
-
-// Overriden exception base class method
-const char* MathematicsException::what() const throw() {
- return std::runtime_error::what();
-}
-
-// Constructor of the DivisionByZeroException class
-DivisionByZeroException::DivisionByZeroException(const std::string& msg)
- :MathematicsException(msg) {
-
-}
-
-// Destructor of the DivisionByZeroException class
-DivisionByZeroException::~DivisionByZeroException() throw() {
-
-}
-
-// Overriden exception base class method
-const char* DivisionByZeroException::what() const throw() {
- return MathematicsException::what();
-}
-
diff --git a/sources/reactphysics3d/mathematics/exceptions.h b/sources/reactphysics3d/mathematics/exceptions.h
deleted file mode 100755
index 785f4d6d..00000000
--- a/sources/reactphysics3d/mathematics/exceptions.h
+++ /dev/null
@@ -1,52 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-#ifndef EXCEPTIONS_H
-#define EXCEPTIONS_H
-
-// Libraries
-#include
-
-// ReactPhysics3D namespace
-namespace reactphysics3d {
-
-/* -------------------------------------------------------------------
- Exception class for the mathematics library
- -------------------------------------------------------------------
-*/
-
-// Class MathematicsException
-class MathematicsException : public std::runtime_error {
- public:
- MathematicsException(const std::string& msg="MathException"); // Constructor
- virtual ~MathematicsException() throw(); // Destructor
- virtual const char* what() const throw(); // Overriding the base exception method
-};
-
-// Class DivisionByZeroException
-class DivisionByZeroException : public MathematicsException {
- public:
- DivisionByZeroException(const std::string& msg="DivisionByZeroException : Division by zero !"); // Constructor
- virtual ~DivisionByZeroException() throw(); // Destructor
- virtual const char* what() const throw(); // Overriding the base exception method
-};
-
-} // End of the ReactPhysics3D namespace
-
-#endif
diff --git a/sources/reactphysics3d/mathematics/mathematics.h b/sources/reactphysics3d/mathematics/mathematics.h
deleted file mode 100644
index bee2d1e1..00000000
--- a/sources/reactphysics3d/mathematics/mathematics.h
+++ /dev/null
@@ -1,34 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-// TODO : Mathematics library : We have to use assert to debug
-// TODO : Mathematics library : Check everywhere that in member methods we use attributes access instead of getter and setter.
-
-#ifndef DCMATHS_H
-#define DCMATHS_H
-
-// Libraries
-#include "Matrix.h"
-#include "Matrix3x3.h"
-#include "Quaternion.h"
-#include "Vector.h"
-#include "Vector3D.h"
-#include "exceptions.h"
-
-#endif
diff --git a/sources/reactphysics3d/reactphysics3d.h b/sources/reactphysics3d/reactphysics3d.h
deleted file mode 100644
index 83b50abd..00000000
--- a/sources/reactphysics3d/reactphysics3d.h
+++ /dev/null
@@ -1,31 +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 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 General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-#ifndef REACTPHYSICS3D_H
-#define REACTPHYSICS3D_H
-
-// ReactPhysics3D namespace
-//namespace reactphysics3d {
-
-// Libraries
-#include "mathematics/mathematics.h"
-
-//} // End of the reactphysics3d namespace
-
-#endif
diff --git a/sources/reactphysics3d/testing/reactphysics3dTestSuite.cpp b/sources/reactphysics3d/testing/reactphysics3dTestSuite.cpp
deleted file mode 100644
index 528625ce..00000000
--- a/sources/reactphysics3d/testing/reactphysics3dTestSuite.cpp
+++ /dev/null
@@ -1,52 +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 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 *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with ReactPhysics3D. If not, see . *
- ***************************************************************************/
-
-// Libraries
-#include
-#include "TestSuite/Suite.h"
-#include "mathematics/VectorTest.h"
-#include "mathematics/Vector3DTest.h"
-#include "mathematics/MatrixTest.h"
-#include "mathematics/Matrix3x3Test.h"
-#include "mathematics/QuaternionTest.h"
-
-// Namespaces
-using namespace std;
-using namespace TestSuite;
-
-// Main function
-int main() {
-
- // ReactPhysics3D TestSuite
- Suite reactphysics3DTestSuite("ReactPhysics3D TestSuite");
-
- // Mathematics Tests
- reactphysics3DTestSuite.addTest(new VectorTest);
- reactphysics3DTestSuite.addTest(new Vector3DTest);
- reactphysics3DTestSuite.addTest(new MatrixTest);
- reactphysics3DTestSuite.addTest(new Matrix3x3Test);
- reactphysics3DTestSuite.addTest(new QuaternionTest);
-
- // Run the ReactPhysics3D TestSuite and display the report
- reactphysics3DTestSuite.run();
- long nbFailures = reactphysics3DTestSuite.report();
- reactphysics3DTestSuite.free();
- return nbFailures;
- double inPause;
- cin >> inPause;
-}