[Jderobot-admin] jderobot-r983 - in trunk/src/stable/libs/geometry: . math progeo

eperdices en jderobot.org eperdices en jderobot.org
Lun Sep 16 21:34:31 CEST 2013


Author: eperdices
Date: 2013-09-16 21:33:31 +0200 (Mon, 16 Sep 2013)
New Revision: 983

Added:
   trunk/src/stable/libs/geometry/Dense.h
Modified:
   trunk/src/stable/libs/geometry/CMakeLists.txt
   trunk/src/stable/libs/geometry/math/Line2D.cpp
   trunk/src/stable/libs/geometry/math/Point2D.cpp
   trunk/src/stable/libs/geometry/math/Point2D.h
   trunk/src/stable/libs/geometry/math/Point3D.cpp
   trunk/src/stable/libs/geometry/math/Point3D.h
   trunk/src/stable/libs/geometry/math/Segment2D.cpp
   trunk/src/stable/libs/geometry/math/geoconst.h
   trunk/src/stable/libs/geometry/progeo/Progeo.h
Log:
A?\195?\177adidas funciones b?\195?\161sicas y modificados .h para que los define no coincidan con otras librer?\195?\173as



Modified: trunk/src/stable/libs/geometry/CMakeLists.txt
===================================================================
--- trunk/src/stable/libs/geometry/CMakeLists.txt	2013-09-16 07:43:37 UTC (rev 982)
+++ trunk/src/stable/libs/geometry/CMakeLists.txt	2013-09-16 19:33:31 UTC (rev 983)
@@ -1,40 +1,21 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+ 
+PROJECT(libgeometry)
+ 
+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.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) 
+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})
 
-ADD_LIBRARY (geometryshare SHARED ${SRC_FILES})
+include(FindPkgConfig)
+find_package(Boost COMPONENTS system filesystem REQUIRED)
 
-SET_TARGET_PROPERTIES (geometryshare PROPERTIES OUTPUT_NAME geometry)
+target_link_libraries(geometry tinyxml GLU opencv_core opencv_highgui ${Boost_LIBRARIES})
 
-TARGET_LINK_LIBRARIES(geometryshare 
-	${gsl_LIBRARIES}
-	${Boost_LIBRARIES}
-	${OpenCV_LIBRARIES}
-	${LIBXML2_LIBRARIES}
-        ${LIBTINYXML_LIBRARIES}
-	${OPENGL_LIBRARIES} 
-	${GLUT_LIBRARY}	
-)
+SET_PROPERTY(TARGET geometry PROPERTY SOVERSION 1.0)
+ 
+#ADD_LIBRARY(geometry_static STATIC ${SRC_FILES})
 
+#target_link_libraries(geometry_shared tinyxml GLU ) 
+#SET_TARGET_PROPERTIES(geometry_shared geometry_static PROPERTIES OUTPUT_NAME geometry)

Added: trunk/src/stable/libs/geometry/Dense.h
===================================================================
--- trunk/src/stable/libs/geometry/Dense.h	                        (rev 0)
+++ trunk/src/stable/libs/geometry/Dense.h	2013-09-16 19:33:31 UTC (rev 983)
@@ -0,0 +1,8 @@
+#include "progeo/Progeo.h"
+#include "math/Line2D.h"
+#include "math/Line3D.h"
+#include "math/Plane3D.h"
+#include "math/Point2D.h"
+#include "math/Point3D.h"
+#include "math/Segment2D.h"
+#include "math/Segment3D.h"

Modified: trunk/src/stable/libs/geometry/math/Line2D.cpp
===================================================================
--- trunk/src/stable/libs/geometry/math/Line2D.cpp	2013-09-16 07:43:37 UTC (rev 982)
+++ trunk/src/stable/libs/geometry/math/Line2D.cpp	2013-09-16 19:33:31 UTC (rev 983)
@@ -105,9 +105,9 @@
 					sqrt(A^2 + B^2)*/
 
 	if(this->v(0) == 0.0 && this->v(1) == 0.0)
-		return G_INFINITE;
+		return GEOMETRY_INFINITE;
 	
-	return abs(this->v(0)*p.getPoint()(0) + this->v(1)*p.getPoint()(1) + this->v(2))/(sqrt(G_SQUARE(this->v(0)) + G_SQUARE(this->v(1))));
+	return abs(this->v(0)*p.getPoint()(0) + this->v(1)*p.getPoint()(1) + this->v(2))/(sqrt(GEOMETRY_SQUARE(this->v(0)) + GEOMETRY_SQUARE(this->v(1))));
 }
 
 double
@@ -117,9 +117,9 @@
 					sqrt(A^2 + B^2)*/
 
 	if(this->v(0) == 0.0 && this->v(1) == 0.0)
-		return G_INFINITE;
+		return GEOMETRY_INFINITE;
 
-	return abs(this->v(2))/(sqrt(G_SQUARE(this->v(0)) + G_SQUARE(this->v(1))));
+	return abs(this->v(2))/(sqrt(GEOMETRY_SQUARE(this->v(0)) + GEOMETRY_SQUARE(this->v(1))));
 }
 
 double
@@ -127,15 +127,15 @@
 	double alpha;
 
 	if(this->v(1) == 0.0)
-		return G_PI_2;
+		return GEOMETRY_PI_2;
 
 	alpha = atan(-this->v(0)/this->v(1));
 
 	/*Normalize*/
 	if(alpha < 0)
-		alpha += G_PI;
-	if(alpha > G_PI)
-		alpha -= G_PI;	
+		alpha += GEOMETRY_PI;
+	if(alpha > GEOMETRY_PI)
+		alpha -= GEOMETRY_PI;	
 
 	return alpha;
 }
@@ -143,7 +143,7 @@
 double
 Line2D::getGradient() {
 	if(this->v(1) == 0.0)
-		return G_INFINITE;
+		return GEOMETRY_INFINITE;
 
 	return -this->v(0)/this->v(1);
 }
@@ -177,10 +177,10 @@
 	diff = this->getAngle() - l.getAngle();
 
 	/*Normalize*/
-	while(diff < -G_PI_2)
-		diff += G_PI;
-	while(diff > G_PI_2)
-		diff -= G_PI;
+	while(diff < -GEOMETRY_PI_2)
+		diff += GEOMETRY_PI;
+	while(diff > GEOMETRY_PI_2)
+		diff -= GEOMETRY_PI;
 
 	return fabs(diff) < threshold;
 }

Modified: trunk/src/stable/libs/geometry/math/Point2D.cpp
===================================================================
--- trunk/src/stable/libs/geometry/math/Point2D.cpp	2013-09-16 07:43:37 UTC (rev 982)
+++ trunk/src/stable/libs/geometry/math/Point2D.cpp	2013-09-16 19:33:31 UTC (rev 983)
@@ -39,6 +39,21 @@
   this->point = p;
 }
 
+void
+Point2D::set(double x, double y, double h) {
+  this->point << x, y, h;
+}
+
+void
+Point2D::set(Eigen::Vector2d &p, double h) {
+  this->point << p(0), p(1), h;
+}
+
+void
+Point2D::set(Eigen::Vector3d &p) {
+  this->point = p;
+}
+
 Eigen::Vector3d&
 Point2D::getPoint() {
   return this->point;
@@ -60,7 +75,7 @@
 
 double
 Point2D::distanceTo(Point2D &p) {
-  return sqrt(G_SQUARE(this->point(0)-p.point(0)) + G_SQUARE(this->point(1)-p.point(1)));
+  return sqrt(GEOMETRY_SQUARE(this->point(0)-p.point(0)) + GEOMETRY_SQUARE(this->point(1)-p.point(1)));
 }
 
 double
@@ -105,7 +120,7 @@
   pe = s.getPointEnd();
 
   tmp = (this->point(0)-ps.point(0))*(pe.point(0)-ps.point(0)) + (this->point(1)-ps.point(1))*(pe.point(1)-ps.point(1));
-  tmp = tmp /(G_SQUARE(pe.point(0)-ps.point(0)) + G_SQUARE(pe.point(1)-ps.point(1)));
+  tmp = tmp /(GEOMETRY_SQUARE(pe.point(0)-ps.point(0)) + GEOMETRY_SQUARE(pe.point(1)-ps.point(1)));
 
   return tmp;
 }

Modified: trunk/src/stable/libs/geometry/math/Point2D.h
===================================================================
--- trunk/src/stable/libs/geometry/math/Point2D.h	2013-09-16 07:43:37 UTC (rev 982)
+++ trunk/src/stable/libs/geometry/math/Point2D.h	2013-09-16 19:33:31 UTC (rev 983)
@@ -40,6 +40,10 @@
   Point2D(Eigen::Vector2d &p, double h=1.0);
   Point2D(Eigen::Vector3d &p);
 
+  void set(double x, double y, double h=1.0);
+  void set(Eigen::Vector2d &p, double h=1.0);
+  void set(Eigen::Vector3d &p);
+
   Eigen::Vector3d& getPoint();
 
   /*Return true if the point is at the infinite*/

Modified: trunk/src/stable/libs/geometry/math/Point3D.cpp
===================================================================
--- trunk/src/stable/libs/geometry/math/Point3D.cpp	2013-09-16 07:43:37 UTC (rev 982)
+++ trunk/src/stable/libs/geometry/math/Point3D.cpp	2013-09-16 19:33:31 UTC (rev 983)
@@ -39,6 +39,21 @@
   this->point = p;
 }
 
+void
+Point3D::set(double x, double y, double z, double h) {
+  this->point << x, y, z, h;
+}
+
+void
+Point3D::set(Eigen::Vector3d &p, double h) {
+  this->point << p(0), p(1), p(2), h;
+}
+
+void
+Point3D::set(Eigen::Vector4d &p) {
+  this->point = p;
+}
+
 Eigen::Vector4d&
 Point3D::getPoint() {
   return this->point;
@@ -60,7 +75,7 @@
 
 double
 Point3D::distanceTo(Point3D &p) {
-  return sqrt(G_SQUARE(this->point(0)-p.point(0)) + G_SQUARE(this->point(1)-p.point(1)) + + G_SQUARE(this->point(2)-p.point(2)));
+  return sqrt(GEOMETRY_SQUARE(this->point(0)-p.point(0)) + GEOMETRY_SQUARE(this->point(1)-p.point(1)) + + GEOMETRY_SQUARE(this->point(2)-p.point(2)));
 }
 
 bool
@@ -73,6 +88,13 @@
   return p.hasPoint(*this);
 }
 
+Point3D&
+Point3D::operator =(const Point3D &pt) {
+  this->point = pt.point;
+
+  return *this;
+}
+
 std::ostream&
 operator <<(std::ostream &o,const Point3D &p) {
   o << "(" << p.point(0) << "," << p.point(1) << "," << p.point(2) << "," << p.point(3) << ")";

Modified: trunk/src/stable/libs/geometry/math/Point3D.h
===================================================================
--- trunk/src/stable/libs/geometry/math/Point3D.h	2013-09-16 07:43:37 UTC (rev 982)
+++ trunk/src/stable/libs/geometry/math/Point3D.h	2013-09-16 19:33:31 UTC (rev 983)
@@ -40,6 +40,10 @@
   Point3D(Eigen::Vector3d &p, double h=1.0);
   Point3D(Eigen::Vector4d &p);
 
+  void set(double x, double y, double z, double h=1.0);
+  void set(Eigen::Vector3d &p, double h=1.0);
+  void set(Eigen::Vector4d &p);
+
   Eigen::Vector4d& getPoint();
 
   /*Return true if the point is at the infinite*/
@@ -58,6 +62,7 @@
   bool belongsToPlane(Plane3D &p);
 
   /*Operators*/
+  Point3D& operator =(const Point3D &pt);
   friend std::ostream& operator <<(std::ostream &o,const Point3D &p);
   
 private:

Modified: trunk/src/stable/libs/geometry/math/Segment2D.cpp
===================================================================
--- trunk/src/stable/libs/geometry/math/Segment2D.cpp	2013-09-16 07:43:37 UTC (rev 982)
+++ trunk/src/stable/libs/geometry/math/Segment2D.cpp	2013-09-16 19:33:31 UTC (rev 983)
@@ -82,15 +82,15 @@
 	diffy = this->pend->getPoint()(1) - this->pstart->getPoint()(1);
 
 	if(diffy == 0.0)
-		return G_PI_2;
+		return GEOMETRY_PI_2;
 
 	alpha = atan(-diffx/diffy);
 
 	/*Normalize*/
 	if(alpha < 0)
-		alpha += G_PI;
-	if(alpha > G_PI)
-		alpha -= G_PI;	
+		alpha += GEOMETRY_PI;
+	if(alpha > GEOMETRY_PI)
+		alpha -= GEOMETRY_PI;	
 
 	return alpha;
 }
@@ -103,7 +103,7 @@
 	diffy = this->pend->getPoint()(1) - this->pstart->getPoint()(1);
 
 	if(diffy == 0.0)
-		return G_INFINITE;
+		return GEOMETRY_INFINITE;
 
 	return -diffx/diffy;
 }
@@ -152,10 +152,10 @@
 	diff = this->getAngle() - s.getAngle();
 
 	/*Normalize*/
-	while(diff < -G_PI_2)
-		diff += G_PI;
-	while(diff > G_PI_2)
-		diff -= G_PI;
+	while(diff < -GEOMETRY_PI_2)
+		diff += GEOMETRY_PI;
+	while(diff > GEOMETRY_PI_2)
+		diff -= GEOMETRY_PI;
 
 	return fabs(diff) < threshold;
 }

Modified: trunk/src/stable/libs/geometry/math/geoconst.h
===================================================================
--- trunk/src/stable/libs/geometry/math/geoconst.h	2013-09-16 07:43:37 UTC (rev 982)
+++ trunk/src/stable/libs/geometry/math/geoconst.h	2013-09-16 19:33:31 UTC (rev 983)
@@ -1,18 +1,18 @@
 #include <iostream>
 
-#ifndef G_SQUARE
-#define G_SQUARE(a) ( (a) * (a) )
+#ifndef GEOMETRY_SQUARE
+#define GEOMETRY_SQUARE(a) ( (a) * (a) )
 #endif
 
-#ifndef G_PI
-#define G_PI 3.1415926535897932384626433832795
+#ifndef GEOMETRY_PI
+#define GEOMETRY_PI 3.1415926535897932384626433832795
 #endif
 
-#ifndef G_PI_2
-#define G_PI_2 1.570796327
+#ifndef GEOMETRY_PI_2
+#define GEOMETRY_PI_2 1.570796327
 #endif
 
-#ifndef G_INFINITE
-#define G_INFINITE 9.9e9
+#ifndef GEOMETRY_INFINITE
+#define GEOMETRY_INFINITE 9.9e9
 #endif
 

Modified: trunk/src/stable/libs/geometry/progeo/Progeo.h
===================================================================
--- trunk/src/stable/libs/geometry/progeo/Progeo.h	2013-09-16 07:43:37 UTC (rev 982)
+++ trunk/src/stable/libs/geometry/progeo/Progeo.h	2013-09-16 19:33:31 UTC (rev 983)
@@ -38,13 +38,6 @@
 #include <libxml/xpath.h>
 #include <libxml/tree.h>
 
-#define PI 3.141592654
-#define BIGNUM 1.0e4
-
-/* geometric distances */
-#define DIST2D(p1,p2) sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y))
-#define DIST3D(p1,p2) sqrt((p1.X-p2.X)*(p1.X-p2.X)+(p1.Y-p2.Y)*(p1.Y-p2.Y)+(p1.Z-p2.Z)*(p1.Z-p2.Z))
-
 namespace Progeo {
 
 class Progeo



More information about the Jderobot-admin mailing list