gucoordinates
CartesianCoordinate.cc
Go to the documentation of this file.
1/*
2 * CartesianCoordinate.cc
3 * gucoordinates
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
60#include "conversions.h"
61
62#if __cplusplus >= 201703L
63#include <optional>
64#endif
65
67
68GU::CartesianCoordinate::CartesianCoordinate(centimetres_t t_x, centimetres_t t_y) NOEXCEPT
69{
70 set_x(t_x);
71 set_y(t_y);
72}
73
75{
76 set_x(other.x());
77 set_y(other.y());
78}
79
81{
82 set_x(other.x);
83 set_y(other.y);
84}
85
86#if __cplusplus >= 201103L
88{
89 set_x(other.x());
90 set_y(other.y());
91}
92
94{
95 set_x(other.x);
96 set_y(other.y);
97}
98#endif
99
101
103{
104 if (&other == this)
105 {
106 return *this;
107 }
108 set_x(other.x());
109 set_y(other.y());
110 return *this;
111}
112
114{
115 if (&other == this)
116 {
117 return *this;
118 }
119 set_x(other.x);
120 set_y(other.y);
121 return *this;
122}
123
124#if __cplusplus >= 201103L
126{
127 if (&other == this) {
128 return *this;
129 }
130 set_x(other.x());
131 set_y(other.y());
132 return *this;
133}
134
136{
137 if (&other == this) {
138 return *this;
139 }
140 set_x(other.x);
141 set_y(other.y);
142 return *this;
143}
144#endif
145
146GU::CartesianCoordinate GU::CartesianCoordinate::cartesianCoordinateAt(const GU::CameraCoordinate &target, const GU::CameraPivot &cameraPivot, const int cameraOffset) const NOEXCEPT
147{
148 return cartesianCoordinateAt(target.relativeCoordinate(cameraPivot, cameraOffset));
149}
150
151GU::CartesianCoordinate GU::CartesianCoordinate::cartesianCoordinateAt(const GU::PixelCoordinate &target, const GU::CameraPivot &cameraPivot, const int cameraOffset) const NOEXCEPT
152{
153 return cartesianCoordinateAt(target.relativeCoordinate(cameraPivot, cameraOffset));
154}
155
156GU::CartesianCoordinate GU::CartesianCoordinate::cartesianCoordinateAt(const GU::PercentCoordinate &target, const GU::CameraPivot &cameraPivot, const int cameraOffset) const NOEXCEPT
157{
158 return cartesianCoordinateAt(target.relativeCoordinate(cameraPivot, cameraOffset));
159}
160
162{
163 return rr_coord_to_cartesian_coord_from_source(target, *this);
164}
165
167{
168 return cartesian_coord_to_rr_coord_from_source(*this, target);
169}
170
172{
173 return relativeCoordinateTo(target.position());
174}
175
176GU::CameraCoordinate GU::CartesianCoordinate::cameraCoordinateTo(const GU::CartesianCoordinate & target, const GU::CameraPivot & cameraPivot, const int cameraOffset, const pixels_u resWidth, const pixels_u resHeight) const NOEXCEPT
177{
178 return relativeCoordinateTo(target).cameraCoordinate(cameraPivot, cameraOffset, resWidth, resHeight);
179}
180
181GU::CameraCoordinate GU::CartesianCoordinate::cameraCoordinateTo(const GU::FieldCoordinate & target, const GU::CameraPivot & cameraPivot, const int cameraOffset, const pixels_u resWidth, const pixels_u resHeight) const NOEXCEPT
182{
183 return relativeCoordinateTo(target).cameraCoordinate(cameraPivot, cameraOffset, resWidth, resHeight);
184}
185
186GU::PixelCoordinate GU::CartesianCoordinate::pixelCoordinateTo(const GU::CartesianCoordinate & target, const GU::CameraPivot & cameraPivot, const int cameraOffset, const pixels_u resWidth, const pixels_u resHeight) const NOEXCEPT
187{
188 return relativeCoordinateTo(target).pixelCoordinate(cameraPivot, cameraOffset, resWidth, resHeight);
189}
190
191GU::PixelCoordinate GU::CartesianCoordinate::pixelCoordinateTo(const GU::FieldCoordinate & target, const GU::CameraPivot & cameraPivot, const int cameraOffset, const pixels_u resWidth, const pixels_u resHeight) const NOEXCEPT
192{
193 return relativeCoordinateTo(target).pixelCoordinate(cameraPivot, cameraOffset, resWidth, resHeight);
194}
195
196GU::PercentCoordinate GU::CartesianCoordinate::percentCoordinateTo(const GU::CartesianCoordinate & target, const GU::CameraPivot & cameraPivot, const int cameraOffset) const NOEXCEPT
197{
198 return relativeCoordinateTo(target).percentCoordinate(cameraPivot, cameraOffset);
199}
200
201GU::PercentCoordinate GU::CartesianCoordinate::percentCoordinateTo(const GU::FieldCoordinate & target, const GU::CameraPivot & cameraPivot, const int cameraOffset) const NOEXCEPT
202{
203 return relativeCoordinateTo(target).percentCoordinate(cameraPivot, cameraOffset);
204}
205
206GU::CameraCoordinate GU::CartesianCoordinate::clampedCameraCoordinateTo(const GU::CartesianCoordinate & target, const GU::CameraPivot & cameraPivot, const int cameraOffset, const pixels_u resWidth, const pixels_u resHeight) const NOEXCEPT
207{
208 return relativeCoordinateTo(target).clampedCameraCoordinate(cameraPivot, cameraOffset, resWidth, resHeight);
209}
210
211GU::CameraCoordinate GU::CartesianCoordinate::clampedCameraCoordinateTo(const GU::FieldCoordinate & target, const GU::CameraPivot & cameraPivot, const int cameraOffset, const pixels_u resWidth, const pixels_u resHeight) const NOEXCEPT
212{
213 return relativeCoordinateTo(target).clampedCameraCoordinate(cameraPivot, cameraOffset, resWidth, resHeight);
214}
215
216GU::PixelCoordinate GU::CartesianCoordinate::clampedPixelCoordinateTo(const GU::CartesianCoordinate & target, const GU::CameraPivot & cameraPivot, const int cameraOffset, const pixels_u resWidth, const pixels_u resHeight) const NOEXCEPT
217{
218 return relativeCoordinateTo(target).clampedPixelCoordinate(cameraPivot, cameraOffset, resWidth, resHeight);
219}
220
221GU::PixelCoordinate GU::CartesianCoordinate::clampedPixelCoordinateTo(const GU::FieldCoordinate & target, const GU::CameraPivot & cameraPivot, const int cameraOffset, const pixels_u resWidth, const pixels_u resHeight) const NOEXCEPT
222{
223 return relativeCoordinateTo(target).clampedPixelCoordinate(cameraPivot, cameraOffset, resWidth, resHeight);
224}
225
226GU::PercentCoordinate GU::CartesianCoordinate::clampedPercentCoordinateTo(const GU::CartesianCoordinate & target, const GU::CameraPivot & cameraPivot, const int cameraOffset) const NOEXCEPT
227{
228 return relativeCoordinateTo(target).clampedPercentCoordinate(cameraPivot, cameraOffset);
229}
230
231GU::PercentCoordinate GU::CartesianCoordinate::clampedPercentCoordinateTo(const GU::FieldCoordinate & target, const GU::CameraPivot & cameraPivot, const int cameraOffset) const NOEXCEPT
232{
233 return relativeCoordinateTo(target).clampedPercentCoordinate(cameraPivot, cameraOffset);
234}
235
236centimetres_t GU::CartesianCoordinate::x() const NOEXCEPT
237{
239}
240
241void GU::CartesianCoordinate::set_x(const centimetres_t newValue) NOEXCEPT
242{
244}
245
246centimetres_t GU::CartesianCoordinate::y() const NOEXCEPT
247{
249}
250
251void GU::CartesianCoordinate::set_y(const centimetres_t newValue) NOEXCEPT
252{
254}
255
257{
258 return gu_cartesian_coordinate_equals(*this, other);
259}
260
262{
263 return !(*this == other);
264}
265
267{
268 return gu_cartesian_coordinate_equals(*this, other);
269}
270
272{
273 return !(*this == other);
274}
275
276
bool gu_cartesian_coordinate_equals(const gu_cartesian_coordinate lhs, const gu_cartesian_coordinate rhs)
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
PercentCoordinate clampedPercentCoordinateTo(const GU::CartesianCoordinate &, const GU::CameraPivot &, const int) const NOEXCEPT
bool operator!=(const CartesianCoordinate &other) const NOEXCEPT
centimetres_t x() const NOEXCEPT
CartesianCoordinate cartesianCoordinateAt(const GU::RelativeCoordinate &) const NOEXCEPT
bool operator==(const CartesianCoordinate &other) const NOEXCEPT
PixelCoordinate clampedPixelCoordinateTo(const GU::CartesianCoordinate &, const GU::CameraPivot &, const int, const pixels_u, const pixels_u) const NOEXCEPT
CartesianCoordinate & operator=(const CartesianCoordinate &other) NOEXCEPT
centimetres_t y() const NOEXCEPT
PercentCoordinate percentCoordinateTo(const GU::CartesianCoordinate &, const GU::CameraPivot &, const int) const NOEXCEPT
CameraCoordinate cameraCoordinateTo(const GU::CartesianCoordinate &, const GU::CameraPivot &, const int, const pixels_u, const pixels_u) const NOEXCEPT
CameraCoordinate clampedCameraCoordinateTo(const GU::CartesianCoordinate &, const GU::CameraPivot &, const int, const pixels_u, const pixels_u) const NOEXCEPT
RelativeCoordinate relativeCoordinateTo(const GU::CartesianCoordinate &) const NOEXCEPT
void set_y(const centimetres_t) NOEXCEPT
PixelCoordinate pixelCoordinateTo(const GU::CartesianCoordinate &, const GU::CameraPivot &, const int, const pixels_u, const pixels_u) const 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.