OrientedPoint.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @author Martin Miller (martin dot miller at student dot kit dot edu)
17 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
18 * GNU General Public License
19 */
20 
21 #include "OrientedPoint.h"
22 
23 using namespace armarx;
24 using namespace Eigen;
25 
27 {
28  px = 0;
29  py = 0;
30  pz = 0;
31 
32  nx = 0;
33  ny = 0;
34  nz = 0;
35 }
36 
37 OrientedPoint::OrientedPoint(const Vector3f& position, const Vector3f& normal)
38 {
39  px = position(0);
40  py = position(1);
41  pz = position(2);
42 
43  nx = normal(0);
44  ny = normal(1);
45  nz = normal(2);
46 }
47 
48 
50 {
51  this->px = px;
52  this->py = py;
53  this->pz = pz;
54 
55  this->nx = nx;
56  this->ny = ny;
57  this->nz = nz;
58 }
59 
61 {
62  Vector3f p;
63  p << this->px, this->py, this->pz;
64  return p;
65 }
66 
68 {
69  Vector3f n;
70  n << this->nx, this->ny, this->nz;
71  return n;
72 }
73 
74 
75 std::string OrientedPoint::output(const Ice::Current& c) const
76 {
77  Eigen::IOFormat vecfmt(Eigen::FullPrecision, 0, "", ", ", "", "", "(", ")");
78  std::stringstream s;
79  s << positionToEigen().format(vecfmt) << ", " << normalToEigen().format(vecfmt);
80  return s.str();
81 }
82 
83 void OrientedPoint::serialize(const ObjectSerializerBasePtr& serializer, const ::Ice::Current&) const
84 {
85  AbstractObjectSerializerPtr obj = AbstractObjectSerializerPtr::dynamicCast(serializer);
86 
87  obj->setFloat("px", px);
88  obj->setFloat("py", py);
89  obj->setFloat("pz", pz);
90 
91  obj->setFloat("nx", nx);
92  obj->setFloat("ny", ny);
93  obj->setFloat("nz", nz);
94 }
95 
96 void OrientedPoint::deserialize(const ObjectSerializerBasePtr& serializer, const ::Ice::Current& c)
97 {
98  AbstractObjectSerializerPtr obj = AbstractObjectSerializerPtr::dynamicCast(serializer);
99 
100  px = obj->getFloat("px");
101  py = obj->getFloat("py");
102  pz = obj->getFloat("pz");
103 
104  nx = obj->getFloat("nx");
105  ny = obj->getFloat("ny");
106  nz = obj->getFloat("nz");
107 }
Eigen
Definition: Elements.h:36
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:918
armarx::OrientedPoint::deserialize
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: OrientedPoint.cpp:96
armarx::OrientedPoint::OrientedPoint
OrientedPoint()
Definition: OrientedPoint.cpp:26
armarx::OrientedPoint::positionToEigen
virtual Eigen::Vector3f positionToEigen() const
Definition: OrientedPoint.cpp:60
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
OrientedPoint.h
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::OrientedPoint::serialize
void serialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: OrientedPoint.cpp:83
armarx::OrientedPoint::output
std::string output(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: OrientedPoint.cpp:75
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx::OrientedPoint::normalToEigen
virtual Eigen::Vector3f normalToEigen() const
Definition: OrientedPoint.cpp:67
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28