[Jderobot-admin] jderobot-r965 - in trunk/src/libs/geometry: . math

eperdices en jderobot.org eperdices en jderobot.org
Mar Ago 6 11:05:17 CEST 2013


Author: eperdices
Date: 2013-08-06 11:04:17 +0200 (Tue, 06 Aug 2013)
New Revision: 965

Added:
   trunk/src/libs/geometry/math/Segment3D.cpp
   trunk/src/libs/geometry/math/Segment3D.h
Modified:
   trunk/src/libs/geometry/CMakeLists.txt
   trunk/src/libs/geometry/math/Line3D.cpp
   trunk/src/libs/geometry/math/Line3D.h
   trunk/src/libs/geometry/math/Segment2D.cpp
Log:
A?\195?\177adida clase Segment3D



Modified: trunk/src/libs/geometry/CMakeLists.txt
===================================================================
--- trunk/src/libs/geometry/CMakeLists.txt	2013-08-05 19:17:22 UTC (rev 964)
+++ trunk/src/libs/geometry/CMakeLists.txt	2013-08-06 09:04:17 UTC (rev 965)
@@ -4,7 +4,7 @@
  
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} /usr/include/libxml2/)
 
-set(SRC_FILES math/matriz3x3.cpp  math/matriz4x4.cpp  math/plano.cpp  math/utils.cpp  math/vector2d.cpp  math/vector3.cpp  math/vector2H.cpp math/vector3H.cpp math/Line2D.cpp math/Segment2D.cpp math/Point2D.cpp math/Point3D.cpp math/Line3D.cpp math/Plane3D collada/colladaparser.cpp collada/color.cpp collada/malla.cpp collada/material.cpp collada/submalla.cpp progeo/Progeo.cpp math/segmento.cpp math/recta.cpp) 
+set(SRC_FILES math/matriz3x3.cpp  math/matriz4x4.cpp  math/plano.cpp  math/utils.cpp  math/vector2d.cpp  math/vector3.cpp  math/vector2H.cpp math/vector3H.cpp math/Line2D.cpp math/Segment2D.cpp math/Point2D.cpp math/Point3D.cpp math/Line3D.cpp math/Plane3D.cpp math/Segment3D.cpp collada/colladaparser.cpp collada/color.cpp collada/malla.cpp collada/material.cpp collada/submalla.cpp progeo/Progeo.cpp math/segmento.cpp math/recta.cpp) 
  
 ADD_LIBRARY(geometry SHARED ${SRC_FILES})
 

Modified: trunk/src/libs/geometry/math/Line3D.cpp
===================================================================
--- trunk/src/libs/geometry/math/Line3D.cpp	2013-08-05 19:17:22 UTC (rev 964)
+++ trunk/src/libs/geometry/math/Line3D.cpp	2013-08-06 09:04:17 UTC (rev 965)
@@ -76,6 +76,15 @@
   return Plane3D(plane);
 }
 
+Point3D
+Line3D::intersectPlane(Plane3D &p) {
+   Eigen::Vector4d point;
+
+  this->plucker_vector2matrix(this->m, this->v);
+  point = this->m * p.getPlane();  
+  return Point3D(point); 
+}
+
 void
 Line3D::plucker_matrix2vector(Eigen::MatrixXd &m, Eigen::VectorXd &v) {
   v << m(0,1), m(0,2), m(0,3), m(1,2), m(3,1), m(2,3);

Modified: trunk/src/libs/geometry/math/Line3D.h
===================================================================
--- trunk/src/libs/geometry/math/Line3D.h	2013-08-05 19:17:22 UTC (rev 964)
+++ trunk/src/libs/geometry/math/Line3D.h	2013-08-06 09:04:17 UTC (rev 965)
@@ -49,6 +49,9 @@
 
   /*Create a plane from a 3D point and current line*/
   Plane3D toPlane(Point3D &p);
+
+  /*Intersect the line with a plane and get a 3D point*/
+  Point3D intersectPlane(Plane3D &p);
  
 private:
 

Modified: trunk/src/libs/geometry/math/Segment2D.cpp
===================================================================
--- trunk/src/libs/geometry/math/Segment2D.cpp	2013-08-05 19:17:22 UTC (rev 964)
+++ trunk/src/libs/geometry/math/Segment2D.cpp	2013-08-06 09:04:17 UTC (rev 965)
@@ -25,6 +25,8 @@
 #include "Point2D.h"
 
 Segment2D::Segment2D() {
+  this->pstart = new Point2D();
+  this->pend = new Point2D();
 }
 
 Segment2D::Segment2D(Point2D &p1, Point2D &p2) {

Added: trunk/src/libs/geometry/math/Segment3D.cpp
===================================================================
--- trunk/src/libs/geometry/math/Segment3D.cpp	                        (rev 0)
+++ trunk/src/libs/geometry/math/Segment3D.cpp	2013-08-06 09:04:17 UTC (rev 965)
@@ -0,0 +1,61 @@
+/*
+ *
+ *  Copyright (C) 1997-2013 JDERobot Developers Team
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published this->pend->getPoint()(1)
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 this program.  If not, see http://www.gnu.org/licenses/. 
+ *
+ *  Authors : Alejandro Hernández <ahcorde [at] gmail [dot] com>
+ *            Roberto Calvo <rocapal [at] gsyc [dot] urjc [dot] es>
+ *            Eduardo Perdices <eperdices [at] gsyc [dot] es>
+ *
+ */
+
+#include "Segment3D.h"
+#include "Point3D.h"
+
+Segment3D::Segment3D() {
+  this->pstart = new Point3D();
+  this->pend = new Point3D();
+}
+
+Segment3D::Segment3D(Point3D &p1, Point3D &p2) {
+  this->pstart = new Point3D(p1.getPoint());
+  this->pend = new Point3D(p2.getPoint());
+}
+
+Point3D&
+Segment3D::getPointStart() {
+  return *(this->pstart);
+}
+
+Point3D&
+Segment3D::getPointEnd() {
+  return *(this->pend);
+}
+
+double
+Segment3D::getLength() {
+  return this->pstart->distanceTo(*(this->pend));
+}
+
+bool
+Segment3D::isPoint() {
+  return this->pstart->getPoint() == this->pend->getPoint();
+}
+
+Line3D
+Segment3D::toLine() {
+  return Line3D(*(this->pstart),*(this->pend));
+}
+

Added: trunk/src/libs/geometry/math/Segment3D.h
===================================================================
--- trunk/src/libs/geometry/math/Segment3D.h	                        (rev 0)
+++ trunk/src/libs/geometry/math/Segment3D.h	2013-08-06 09:04:17 UTC (rev 965)
@@ -0,0 +1,62 @@
+/*
+ *
+ *  Copyright (C) 1997-2013 JDERobot Developers Team
+ *
+ *  This program 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.
+ *
+ *  This program 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 this program.  If not, see http://www.gnu.org/licenses/. 
+ *
+ *  Authors : Alejandro Hernández <ahcorde [at] gmail [dot] com>
+ *            Roberto Calvo <rocapal [at] gsyc [dot] urjc [dot] es>
+ *            Eduardo Perdices <eperdices [at] gsyc [dot] es>
+ *
+ *
+ *
+ *  Segment3D: Represents a 3D Segment represented by 2 3D Points
+ */
+
+#ifndef SEGMENT3D_H
+#define SEGMENT3D_H
+#define EIGEN_DONT_ALIGN_STATICALLY True
+
+#include <math.h>
+#include <eigen3/Eigen/Dense>
+#include "geoconst.h"
+#include "Line3D.h"
+
+class Point3D;
+
+class Segment3D {
+public:
+  Segment3D();
+  Segment3D(Point3D &p1, Point3D &p2);
+
+  Point3D& getPointStart();
+  Point3D& getPointEnd();
+
+  /*Get segment length*/
+  double getLength();
+
+  /*Return true if the segment is a point*/
+  bool isPoint();
+
+  /*Convert 3D segment into a 3D line*/
+  Line3D toLine();
+  
+private:
+
+  Point3D *pstart;
+  Point3D *pend;
+    
+};
+
+#endif



More information about the Jderobot-admin mailing list