gucoordinates
CartesianCoordinateTests.cc
Go to the documentation of this file.
1/*
2 * CartesianCoordinateTests.cc
3 * tests
4 *
5 * Created by Callum McColl on 21/06/2020.
6 * Copyright © 2020 Callum McColl. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials
18 * provided with the distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgement:
22 *
23 * This product includes software developed by Callum McColl.
24 *
25 * 4. Neither the name of the author nor the names of contributors
26 * may be used to endorse or promote products derived from this
27 * software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
33 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
34 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
35 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
36 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
37 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
38 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * -----------------------------------------------------------------------
42 * This program is free software; you can redistribute it and/or
43 * modify it under the above terms or under the terms of the GNU
44 * General Public License as published by the Free Software Foundation;
45 * either version 2 of the License, or (at your option) any later version.
46 *
47 * This program is distributed in the hope that it will be useful,
48 * but WITHOUT ANY WARRANTY; without even the implied warranty of
49 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50 * GNU General Public License for more details.
51 *
52 * You should have received a copy of the GNU General Public License
53 * along with this program; if not, see http://www.gnu.org/licenses/
54 * or write to the Free Software Foundation, Inc., 51 Franklin Street,
55 * Fifth Floor, Boston, MA 02110-1301, USA.
56 *
57 */
58
59#include "GUWrapperTests.hpp"
60
61namespace CGTEST {
62
63 class CartesianCoordinateCPPTests: public GUWrapperTests<GU::CartesianCoordinate, gu_cartesian_coordinate> {
64
65 protected:
66
68 {
69 return GU::CartesianCoordinate(90, 100);
70 }
71
73 {
74 return GU::CartesianCoordinate(0, 0);
75 }
76
78 {
79 obj.set_x(-90);
80 }
81
83 {
84 obj.x = 40;
85 obj.y = 15;
86 }
87
89 {
90 return empty();
91 }
92
93 };
94
96
97 GETTER_IM_TEST_NAME_F(CartesianCoordinate, cartesianCoordinateCamera, CartesianCoordinate, rr_coord_to_cartesian_coord_from_source, RelativeCoordinate, pct_coord_to_rr_coord, cartesianCoordinateAt(GU::CameraCoordinate(23, 52, 1920, 1080), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX))
98 GETTER_IM_TEST_NAME_F(CartesianCoordinate, cartesianCoordinatePixel, CartesianCoordinate, rr_coord_to_cartesian_coord_from_source, RelativeCoordinate, pct_coord_to_rr_coord, cartesianCoordinateAt(GU::PixelCoordinate(42, -123, 1920, 1080), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX))
99 GETTER_IM_TEST_NAME_F(CartesianCoordinate, cartesianCoordinatePercent, CartesianCoordinate, rr_coord_to_cartesian_coord_from_source, RelativeCoordinate, pct_coord_to_rr_coord, cartesianCoordinateAt(GU::PercentCoordinate(-0.24, 0.5), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX))
100
101 GETTER_TEST_F(CartesianCoordinate, CartesianCoordinate, rr_coord_to_cartesian_coord_from_source, cartesianCoordinateAt(GU::RelativeCoordinate(10, 123)))
102 GETTER_TEST_NAME_F(CartesianCoordinate, RelativeCoordinateCartesian, RelativeCoordinate, cartesian_coord_to_rr_coord_from_source, relativeCoordinateTo(GU::CartesianCoordinate(123, 323)))
103 GETTER_TEST_NAME_F(CartesianCoordinate, RelativeCoordinateField, RelativeCoordinate, cartesian_coord_to_rr_coord_from_source, relativeCoordinateTo(GU::FieldCoordinate(GU::CartesianCoordinate(123, 323), -50)))
104
105 GETTER_TEST_NAME_F(CartesianCoordinate, percentCoordinateCartesian, PercentCoordinate, rr_coord_to_pct_coord, percentCoordinateTo(GU::CartesianCoordinate(-3, 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX))
106 GETTER_TEST_NAME_F(CartesianCoordinate, percentCoordinateField, PercentCoordinate, rr_coord_to_pct_coord, percentCoordinateTo(GU::FieldCoordinate(GU::CartesianCoordinate(23, 100), 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX))
107
108 GETTER_IM_TEST_NAME_F(CartesianCoordinate, pixelCoordinateCartesian, PixelCoordinate, pct_coord_to_px_coord, PercentCoordinate, rr_coord_to_pct_coord, pixelCoordinateTo(GU::CartesianCoordinate(-3, 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 1920, 1080))
109 GETTER_IM_TEST_NAME_F(CartesianCoordinate, pixelCoordinateField, PixelCoordinate, pct_coord_to_px_coord, PercentCoordinate, rr_coord_to_pct_coord, pixelCoordinateTo(GU::FieldCoordinate(GU::CartesianCoordinate(23, 100), 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 1920, 1080))
110
111 GETTER_IM_TEST_NAME_F(CartesianCoordinate, cameraCoordinateCartesian, CameraCoordinate, px_coord_to_cam_coord, PercentCoordinate, rr_coord_to_pct_coord, cameraCoordinateTo(GU::CartesianCoordinate(-3, 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 1920, 1080))
112 GETTER_IM_TEST_NAME_F(CartesianCoordinate, cameraCoordinateField, CameraCoordinate, px_coord_to_cam_coord, PercentCoordinate, rr_coord_to_pct_coord, cameraCoordinateTo(GU::FieldCoordinate(GU::CartesianCoordinate(23, 100), 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 1920, 1080))
113
114 GETTER_TEST_NAME_F(CartesianCoordinate, clampedPercentCoordinateCartesian, PercentCoordinate, clamped_rr_coord_to_pct_coord, clampedPercentCoordinateTo(GU::CartesianCoordinate(-3, 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX))
115 GETTER_TEST_NAME_F(CartesianCoordinate, clampedPercentCoordinateField, PercentCoordinate, clamped_rr_coord_to_pct_coord, clampedPercentCoordinateTo(GU::FieldCoordinate(GU::CartesianCoordinate(23, 100), 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX))
116
117 GETTER_IM_TEST_NAME_F(CartesianCoordinate, clampedPixelCoordinateCartesian, PixelCoordinate, pct_coord_to_px_coord, PercentCoordinate, clamped_rr_coord_to_pct_coord, clampedPixelCoordinateTo(GU::CartesianCoordinate(-3, 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 1920, 1080))
118 GETTER_IM_TEST_NAME_F(CartesianCoordinate, clampedPixelCoordinateField, PixelCoordinate, pct_coord_to_px_coord, PercentCoordinate, clamped_rr_coord_to_pct_coord, clampedPixelCoordinateTo(GU::FieldCoordinate(GU::CartesianCoordinate(23, 100), 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 1920, 1080))
119
120 GETTER_IM_TEST_NAME_F(CartesianCoordinate, clampedCameraCoordinateCartesian, CameraCoordinate, px_coord_to_cam_coord, PercentCoordinate, clamped_rr_coord_to_pct_coord, clampedCameraCoordinateTo(GU::CartesianCoordinate(-3, 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 1920, 1080))
121 GETTER_IM_TEST_NAME_F(CartesianCoordinate, clampedCameraCoordinateField, CameraCoordinate, px_coord_to_cam_coord, PercentCoordinate, clamped_rr_coord_to_pct_coord, clampedCameraCoordinateTo(GU::FieldCoordinate(GU::CartesianCoordinate(23, 100), 12), nao, GU_NAO_V5_BOTTOM_CAMERA_INDEX, 1920, 1080))
122
123
126 ASSERT_EQ(coord.x(), 90);
127 coord.set_x(-90);
128 ASSERT_EQ(coord.x(), -90);
129 ASSERT_EQ(coord.y(), 100);
130 coord.set_y(10);
131 ASSERT_EQ(coord.y(), 10);
132 }
133
134} // namespace
#define GETTER_IM_TEST_NAME_F(className, testName, resultType, call, imType, imCall, get)
#define WRAPPER_TEST_Fs(className, strctName)
#define GETTER_TEST_NAME_F(className, testName, resultType, call, get)
#define GETTER_TEST_F(className, resultType, call, get)
void change(GU::CartesianCoordinate &obj)
void cchange(gu_cartesian_coordinate &obj)
gu_percent_coordinate clamped_rr_coord_to_pct_coord(const gu_relative_coordinate coord, const gu_camera_pivot camera_pivot, const int cameraOffset)
Definition: conversions.c:157
gu_relative_coordinate cartesian_coord_to_rr_coord_from_source(const gu_cartesian_coordinate source, const gu_cartesian_coordinate target)
Definition: conversions.c:226
gu_cartesian_coordinate rr_coord_to_cartesian_coord_from_source(const gu_relative_coordinate coord, const gu_cartesian_coordinate source)
Definition: conversions.c:188
gu_camera_coordinate px_coord_to_cam_coord(const gu_pixel_coordinate coord)
Definition: conversions.c:85
gu_pixel_coordinate pct_coord_to_px_coord(const gu_percent_coordinate coord, const pixels_u res_width, const pixels_u res_height)
Definition: conversions.c:105
gu_relative_coordinate pct_coord_to_rr_coord(const gu_percent_coordinate coord, const gu_camera_pivot camera_pivot, const int cameraOffset)
Definition: conversions.c:115
gu_percent_coordinate rr_coord_to_pct_coord(const gu_relative_coordinate coord, const gu_camera_pivot camera_pivot, const int cameraOffset)
Definition: conversions.c:142
#define GU_NAO_V5_BOTTOM_CAMERA_INDEX
TEST_F(CameraCoordinateTests, Equality)
Definition: Camera.hpp:66
centimetres_t x() const NOEXCEPT
centimetres_t y() const NOEXCEPT
void set_y(const centimetres_t) NOEXCEPT
void set_x(const centimetres_t) NOEXCEPT
A cartesian_coordinate is a general coordinate for representing positions on a tow dimensional plane.
millimetres_t y
The y coordinate of the position in centimetres.
millimetres_t x
The x coordinate of the position in centimetres.