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 
49  ::Ice::Float py,
50  ::Ice::Float pz,
51  ::Ice::Float nx,
52  ::Ice::Float ny,
53  ::Ice::Float nz)
54 {
55  this->px = px;
56  this->py = py;
57  this->pz = pz;
58 
59  this->nx = nx;
60  this->ny = ny;
61  this->nz = nz;
62 }
63 
64 Vector3f
66 {
67  Vector3f p;
68  p << this->px, this->py, this->pz;
69  return p;
70 }
71 
72 Vector3f
74 {
75  Vector3f n;
76  n << this->nx, this->ny, this->nz;
77  return n;
78 }
79 
80 std::string
81 OrientedPoint::output(const Ice::Current& c) const
82 {
83  Eigen::IOFormat vecfmt(Eigen::FullPrecision, 0, "", ", ", "", "", "(", ")");
84  std::stringstream s;
85  s << positionToEigen().format(vecfmt) << ", " << normalToEigen().format(vecfmt);
86  return s.str();
87 }
88 
89 void
90 OrientedPoint::serialize(const ObjectSerializerBasePtr& serializer, const ::Ice::Current&) const
91 {
92  AbstractObjectSerializerPtr obj = AbstractObjectSerializerPtr::dynamicCast(serializer);
93 
94  obj->setFloat("px", px);
95  obj->setFloat("py", py);
96  obj->setFloat("pz", pz);
97 
98  obj->setFloat("nx", nx);
99  obj->setFloat("ny", ny);
100  obj->setFloat("nz", nz);
101 }
102 
103 void
104 OrientedPoint::deserialize(const ObjectSerializerBasePtr& serializer, const ::Ice::Current& c)
105 {
106  AbstractObjectSerializerPtr obj = AbstractObjectSerializerPtr::dynamicCast(serializer);
107 
108  px = obj->getFloat("px");
109  py = obj->getFloat("py");
110  pz = obj->getFloat("pz");
111 
112  nx = obj->getFloat("nx");
113  ny = obj->getFloat("ny");
114  nz = obj->getFloat("nz");
115 }
Eigen
Definition: Elements.h:32
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:919
armarx::OrientedPoint::deserialize
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: OrientedPoint.cpp:104
armarx::OrientedPoint::OrientedPoint
OrientedPoint()
Definition: OrientedPoint.cpp:26
armarx::OrientedPoint::positionToEigen
virtual Eigen::Vector3f positionToEigen() const
Definition: OrientedPoint.cpp:65
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
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:90
armarx::OrientedPoint::output
std::string output(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: OrientedPoint.cpp:81
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:73
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27