YARP
Yet Another Robot Platform
LaserMeasurementData.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
7#include <cmath>
8
9using namespace yarp::dev;
10
11LaserMeasurementData::LaserMeasurementData()
12{
13 stored_x = stored_y = stored_angle = stored_distance = 0;
14}
15
16void LaserMeasurementData::set_cartesian(const double x, const double y)
17{
18 stored_x = x; stored_y = y; stored_distance = sqrt(x*x + y*y); stored_angle = atan2(y, x);
19}
20
21void LaserMeasurementData::set_polar(const double rho, const double theta)
22{
23 stored_angle = theta; stored_distance = rho; stored_y = rho*sin(theta); stored_x = rho*cos(theta);
24}
25
26void LaserMeasurementData::get_cartesian(double& x, double& y)
27{
28 x = stored_x; y = stored_y;
29}
30
31void LaserMeasurementData::get_polar(double& rho, double& theta)
32{
33 rho = stored_distance; theta = stored_angle;
34}
void set_cartesian(const double x, const double y)
void get_cartesian(double &x, double &y)
void get_polar(double &rho, double &theta)
void set_polar(const double rho, const double theta)
For streams capable of holding different kinds of content, check what they actually have.