git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@269 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
13d79612a0
commit
83345270f1
|
@ -1,56 +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 "Polygon3D.h"
|
||||
|
||||
// We want to use the ReactPhysics3D namespace
|
||||
using namespace reactphysics3d;
|
||||
|
||||
// Constructor
|
||||
Polygon3D::Polygon3D(const std::vector<Vector3D>& vertexList)
|
||||
:vertexList(vertexList) {
|
||||
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Polygon3D::~Polygon3D() {
|
||||
|
||||
}
|
||||
|
||||
// TODO : Delete this function if not needed
|
||||
// Return true if a point is in the same plane and inside the polygon
|
||||
// Hypothesis : The point has to be on the same plane as the polygon.
|
||||
/*
|
||||
bool Polygon3D::isPointInside(const Vector3D& point) const {
|
||||
// TODO : Implement this method
|
||||
}
|
||||
*/
|
||||
|
||||
// TODO : Delete this function if not needed
|
||||
// Return the intersection point between a segment and an egde of the polygon.
|
||||
// Hypothesis : The segment must be in the same plane as the polygon and it
|
||||
// must intersection with at least one edge of the polygon.
|
||||
/*
|
||||
Vector3D Polygon3D::getEdgeIntersectionWithSegment(const Segment3D& segment) const {
|
||||
// TODO : Implement this method
|
||||
}
|
||||
*/
|
||||
|
||||
|
|
@ -1,74 +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 POLYGON3D_H
|
||||
#define POLYGON3D_H
|
||||
|
||||
// Libraries
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
#include "Vector3D.h"
|
||||
|
||||
// ReactPhysics3D namespace
|
||||
namespace reactphysics3d {
|
||||
|
||||
/* -------------------------------------------------------------------
|
||||
Class Polygon3D :
|
||||
This class represents a 3D polygon.
|
||||
-------------------------------------------------------------------
|
||||
*/
|
||||
class Polygon3D {
|
||||
private :
|
||||
std::vector<Vector3D> vertexList; // Ordered list of all vertices of the polygon
|
||||
|
||||
public :
|
||||
Polygon3D(const std::vector<Vector3D>& vertexList); // Constructor
|
||||
~Polygon3D(); // Destructor
|
||||
|
||||
int getNbVertex() const; // Return the number of vertex of the polygon
|
||||
Vector3D getVertex(unsigned int index) const throw(std::invalid_argument); // Return a vertex of the polygon
|
||||
bool isPointInside(const Vector3D& point) const; // Return true if a point is in the same plane and inside the polygon
|
||||
// TODO : Delete the following function if not needed
|
||||
//Vector3D getEdgeIntersectionWithSegment(const Segment3D& segment) const; // Return the intersection point between a segment and an egde of the polygon
|
||||
};
|
||||
|
||||
// TODO : Test the Polygon3D class
|
||||
|
||||
// Return the number of vertex of the polygon
|
||||
inline int Polygon3D::getNbVertex() const {
|
||||
return vertexList.size();
|
||||
}
|
||||
|
||||
// Return a vertex of the polygon
|
||||
inline Vector3D Polygon3D::getVertex(unsigned int index) const throw(std::invalid_argument) {
|
||||
// Check if the index argument is valid
|
||||
if (index >= 0 && index < vertexList.size()) {
|
||||
return vertexList[index];
|
||||
}
|
||||
else {
|
||||
// The index is invalid, we throw an exception
|
||||
throw std::invalid_argument("Exception : The index argument has to be between zero and the number of vertex of the polygon");
|
||||
}
|
||||
}
|
||||
|
||||
} // End of the ReactPhysics3D namespace
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,40 +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 "Segment3D.h"
|
||||
|
||||
// Namespace
|
||||
using namespace reactphysics3d;
|
||||
|
||||
// Constructor
|
||||
Segment3D::Segment3D() {
|
||||
|
||||
}
|
||||
|
||||
// Constructor with arguments
|
||||
Segment3D::Segment3D(const Vector3D& pointA, const Vector3D& pointB) {
|
||||
this->pointA = pointA;
|
||||
this->pointB = pointB;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Segment3D::~Segment3D() {
|
||||
|
||||
}
|
|
@ -1,89 +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 SEGMENT3D_H
|
||||
#define SEGMENT3D_H
|
||||
|
||||
// Libraries
|
||||
#include "Vector3D.h"
|
||||
|
||||
// ReactPhysics3D namespace
|
||||
namespace reactphysics3d {
|
||||
|
||||
/* -------------------------------------------------------------------
|
||||
Class Segment3D :
|
||||
This class represents a line segment in a 3D space. A segment is
|
||||
described by two points A and B.
|
||||
-------------------------------------------------------------------
|
||||
*/
|
||||
class Segment3D {
|
||||
private :
|
||||
Vector3D pointA; // Point A of the line segment
|
||||
Vector3D pointB; // Point B of the line segment
|
||||
|
||||
public :
|
||||
Segment3D(); // Constructor
|
||||
Segment3D(const Vector3D& pointA, const Vector3D& pointB); // Constructor with arguments
|
||||
~Segment3D(); // Destructor
|
||||
|
||||
Vector3D getPointA() const; // Return the point A
|
||||
void setPointA(const Vector3D& pointA); // Set the point A
|
||||
Vector3D getPointB() const; // Return the point B
|
||||
void setPointB(const Vector3D& pointB); // Set the point B
|
||||
Vector3D getSegmentVector() const; // Return the vector between points A and B
|
||||
double getLength() const; // Return the length of the segment
|
||||
};
|
||||
|
||||
// TODO : Test the Segment3D class
|
||||
|
||||
// Return the point A
|
||||
inline Vector3D Segment3D::getPointA() const {
|
||||
return pointA;
|
||||
}
|
||||
|
||||
// Set the point A
|
||||
inline void Segment3D::setPointA(const Vector3D& pointA) {
|
||||
this->pointA = pointA;
|
||||
}
|
||||
|
||||
// Get the point B
|
||||
inline Vector3D Segment3D::getPointB() const {
|
||||
return pointB;
|
||||
}
|
||||
|
||||
// Set the point B
|
||||
inline void Segment3D::setPointB(const Vector3D& pointB) {
|
||||
this->pointB = pointB;
|
||||
}
|
||||
|
||||
// Return the vector between points A and B
|
||||
inline Vector3D Segment3D::getSegmentVector() const {
|
||||
return (pointB - pointA);
|
||||
}
|
||||
|
||||
// Return the length of the segment
|
||||
inline double Segment3D::getLength() const {
|
||||
return (pointB - pointA).length();
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // End of the ReactPhysics3D namespace
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user