[Jderobot-admin] jderobot-r967 - trunk/src/libs/geometry/math
rocapal en jderobot.org
rocapal en jderobot.org
Lun Ago 12 08:34:28 CEST 2013
Author: rocapal
Date: 2013-08-12 08:33:28 +0200 (Mon, 12 Aug 2013)
New Revision: 967
Modified:
trunk/src/libs/geometry/math/Segment3D.cpp
trunk/src/libs/geometry/math/Segment3D.h
Log:
#26 added methods to getPoint given the distance
Modified: trunk/src/libs/geometry/math/Segment3D.cpp
===================================================================
--- trunk/src/libs/geometry/math/Segment3D.cpp 2013-08-06 11:17:33 UTC (rev 966)
+++ trunk/src/libs/geometry/math/Segment3D.cpp 2013-08-12 06:33:28 UTC (rev 967)
@@ -3,7 +3,7 @@
* 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)
+ * 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.
*
@@ -16,6 +16,7 @@
* along with this program. If not, see http://www.gnu.org/licenses/.
*
* Authors : Eduardo Perdices <eperdices [at] gsyc [dot] es>
+ * Roberto Calvo <rocapal [at] gsyc [dot] urjc [dot] es>
*
*/
@@ -63,3 +64,27 @@
return o;
}
+Point3D*
+Segment3D::getPointByZ (const float Z)
+{
+
+ // create Vector
+ double x,y,z,t;
+ x = pstart->getPoint()(0) - pend->getPoint()(0);
+ y = pstart->getPoint()(1) - pend->getPoint()(1);
+ z = pstart->getPoint()(2) - pend->getPoint()(2);
+
+ Point3D *vector = new Point3D(x,y,z);
+
+ // pstart and vector define the segment in parametrics
+ t = (Z - pstart->getPoint()(2)) / vector->getPoint()(2);
+ x = pstart->getPoint()(0) + t*vector->getPoint()(0);
+ y = pstart->getPoint()(1) + t*vector->getPoint()(1);
+ z = Z;
+
+ delete(vector);
+
+ Point3D* res = new Point3D(x,y,z);
+ return res;
+}
+
Modified: trunk/src/libs/geometry/math/Segment3D.h
===================================================================
--- trunk/src/libs/geometry/math/Segment3D.h 2013-08-06 11:17:33 UTC (rev 966)
+++ trunk/src/libs/geometry/math/Segment3D.h 2013-08-12 06:33:28 UTC (rev 967)
@@ -16,6 +16,7 @@
* along with this program. If not, see http://www.gnu.org/licenses/.
*
* Authors : Eduardo Perdices <eperdices [at] gsyc [dot] es>
+ * Roberto Calvo <rocapal [at] gsyc [dot] urjc [dot] es>
*
*
*
@@ -53,6 +54,10 @@
/*Operators*/
friend std::ostream& operator <<(std::ostream &o,const Segment3D &s);
+ /*Get point with a specific distance from pstart*/
+ Point3D* getPointByZ (const float Z);
+
+
private:
Point3D *pstart;
More information about the Jderobot-admin
mailing list