70 #define M_PI_2 1.57079632679489661923
73#define RELATIVE_COORD_MAX_DISTANCE f_to_mm_u(FLT_MAX)
77 const pixels_u maxX = coord.
res_width - 1;
78 const pixels_t x = px_u_to_px_t(coord.
x) - d_to_px_t(floor(px_u_to_d(maxX) / 2.0));
80 const pixels_t y = px_u_to_px_t(maxY - coord.
y) - d_to_px_t(floor(px_u_to_d(maxY) / 2.0));
87 const pixels_u maxX = coord.
res_width - 1;
88 const pixels_u x = px_t_to_px_u(coord.
x + d_to_px_t(floor(px_u_to_d(maxX) / 2.0)));
90 const pixels_u y = px_t_to_px_u(-coord.
y - d_to_px_t(floor(px_u_to_d(maxY) / 2.0)) + px_u_to_px_t(maxY));
97 const pixels_t maxX = px_u_to_px_t(coord.
res_width) - 1;
98 const pixels_t maxY = px_u_to_px_t(coord.
res_height) - 1;
99 const double x = px_t_to_d(2 * coord.
x - (maxX % 2)) / px_t_to_d(maxX);
100 const double y = px_t_to_d(2 * coord.
y - (maxY % 2)) / px_t_to_d(maxY);
107 const pixels_t maxX = px_u_to_px_t(res_width) - 1;
108 const pixels_t maxY = px_u_to_px_t(res_height) - 1;
109 const double pixelsX = (pct_d_to_d(coord.
x) * px_t_to_d(maxX) + px_t_to_d(maxX % 2)) / 2.0;
110 const double pixelsY = (pct_d_to_d(coord.
y) * px_t_to_d(maxY) + px_t_to_d(maxY % 2)) / 2.0;
111 const gu_pixel_coordinate newCoord = { d_to_px_t(pixelsX), d_to_px_t(pixelsY), res_width, res_height };
118 const degrees_d pitchToObject = camera_pivot.
pitch + camera.
vDirection - d_to_deg_d(pct_d_to_d(coord.
y)) * (camera.
vFov / 2.0);
119 const degrees_d yaw = camera_pivot.
yaw - d_to_deg_d(pct_d_to_d(coord.
x)) * (camera.
hFov / 2.0);
121 if (pitchToObject >= 90.0)
126 const radians_d pitchRad = deg_d_to_rad_d(pitchToObject);
127 const radians_d yawRad = deg_d_to_rad_d(yaw);
128 const double cosYaw = cos(rad_d_to_d(yawRad));
130 if (pitchToObject <= 0.0 || fabs(cosYaw) < 0.00001)
136 const double distance = cm_d_to_d(actualCameraHeight) * tan((
M_PI_2) - rad_d_to_d(pitchRad)) / cosYaw;
137 const centimetres_d outDistance = d_to_cm_d(distance) - camera.
centerOffset;
145 const degrees_d yaw = coord.
direction - camera_pivot.
yaw;
146 const percent_d x = d_to_pct_d(deg_d_to_d(-yaw / (camera.
hFov / 2.0)));
147 const radians_d yawRad = deg_d_to_rad_d(coord.
direction);
148 const double frontDistance = cm_d_to_d(mm_u_to_cm_d(coord.
distance)) * cos(rad_d_to_d(yawRad)) + cm_d_to_d(camera.
centerOffset);
150 const degrees_d totalPitch = 90.0 - rad_d_to_deg_d(d_to_rad_d(atan2(frontDistance, cm_d_to_d(actualCameraHeight))));
151 const degrees_d pitch = totalPitch - camera.
vDirection - camera_pivot.
pitch;
152 const percent_d y = d_to_pct_d(deg_d_to_d(-pitch / (camera.
vFov / 2.0)));
164 else if (temp.
x > 1.0) {
171 else if (temp.
y > 1.0) {
179 const double distance = mm_u_to_d(coord.
distance);
180 const double rads = rad_d_to_d(deg_d_to_rad_d(coord.
direction));
182 d_to_mm_t(distance * cos(rads)),
183 d_to_mm_t(distance * sin(rads))
191 temp.
x = source.
x + temp.
x;
192 temp.
y = source.
y + temp.
y;
231 rad_d_to_deg_d(angle),
232 mm_d_to_mm_u(fabs(distance))
246 const millimetres_t dx = p2.
x - p1.
x;
247 const millimetres_t dy = p2.
y - p1.
y;
252 return dy > 0 ? d_to_rad_d(90.0) : d_to_rad_d(-90.0);
254 return d_to_rad_d(atan2(mm_t_to_d(dy), mm_t_to_d(dx)));
262 return fabs(mm_t_to_d(dpoint.
y));
266 return fabs(mm_t_to_d(dpoint.
x));
268 return d_to_mm_d(sqrt(mm_t_to_d(dpoint.
x * dpoint.
x) + mm_t_to_d(dpoint.
y * dpoint.
y)));
272 if (angle + 180.0 == 0.0)
277 angle = fmod(angle, -360);
279 angle = fmod(angle, 360);
centimetres_d gu_camera_pivot_calculate_camera_height(const gu_camera_pivot camera_pivot, const int cameraOffset)
gu_percent_coordinate px_coord_to_pct_coord(const gu_pixel_coordinate coord)
gu_cartesian_coordinate rr_coord_to_cartesian_coord(const gu_relative_coordinate coord)
gu_percent_coordinate clamped_rr_coord_to_pct_coord(const gu_relative_coordinate coord, const gu_camera_pivot camera_pivot, const int cameraOffset)
radians_d angle_between_points(const gu_cartesian_coordinate p1, const gu_cartesian_coordinate p2)
gu_relative_coordinate cartesian_coord_to_rr_coord_from_source(const gu_cartesian_coordinate source, const gu_cartesian_coordinate target)
degrees_t normalise_deg_t(degrees_t angle)
gu_cartesian_coordinate rr_coord_to_cartesian_coord_from_source(const gu_relative_coordinate coord, const gu_cartesian_coordinate source)
#define RELATIVE_COORD_MAX_DISTANCE
gu_field_coordinate rr_coord_to_field_coord_from_source(const gu_relative_coordinate coord, const gu_field_coordinate source, const degrees_t heading)
gu_camera_coordinate px_coord_to_cam_coord(const gu_pixel_coordinate coord)
gu_pixel_coordinate pct_coord_to_px_coord(const gu_percent_coordinate coord, const pixels_u res_width, const pixels_u res_height)
gu_cartesian_coordinate rr_coord_to_cartesian_coord_from_field(const gu_relative_coordinate coord, const gu_field_coordinate source)
gu_relative_coordinate pct_coord_to_rr_coord(const gu_percent_coordinate coord, const gu_camera_pivot camera_pivot, const int cameraOffset)
millimetres_d distance_between_points(const gu_cartesian_coordinate point1, const gu_cartesian_coordinate point2)
gu_pixel_coordinate cam_coord_to_px_coord(const gu_camera_coordinate coord)
degrees_d normalise_deg_d(degrees_d angle)
gu_percent_coordinate rr_coord_to_pct_coord(const gu_relative_coordinate coord, const gu_camera_pivot camera_pivot, const int cameraOffset)
radians_d normalise_rad_d(radians_d angle)
gu_relative_coordinate cartesian_coord_to_rr_coord(const gu_cartesian_coordinate target)
gu_relative_coordinate field_coord_to_rr_coord_to_target(const gu_field_coordinate source, const gu_cartesian_coordinate target)
gu_field_coordinate rr_coord_to_field_coord(const gu_relative_coordinate coord, const degrees_t heading)
A gu_camera_coordinate represents the coordinate of a pixel within an image where the (0,...
pixels_u x
The x coordinate of the pixel within the image.
pixels_u res_height
The height of the resolution of the image.
pixels_u res_width
The width of the resolution of the image.
pixels_u y
The y coordinate of the pixel within the image.
A gu_camera_pivot represents the pivot point which a gu_camera is attached to.
degrees_d pitch
The vertical orientation of the pivot point.
degrees_d yaw
The horizontal orientation of the pivot point.
gu_camera cameras[2]
The gu_cameras attached to this pivot point.
centimetres_d centerOffset
The distance the camera is from the center point.
degrees_d hFov
The horizontal field of view.
degrees_d vFov
The vertical field of view.
degrees_d vDirection
The degree in which the camera is facing in the vertical direction.
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.
A field_coordinate is a coordinate for an object that faces a certain direction (such as a robot) on ...
degrees_t heading
The direction where the object is facing.
gu_cartesian_coordinate position
The position of the object on the field.
A gu_percent_coordinate represents the coordinate of a pixel within an image.
percent_d y
The y coordinate of the pixel within the image as a percentage.
percent_d x
The x coordinate of the pixel within the image as a percentage.
A gu_pixel_coordinate represents the coordinate of a pixel within an image.
pixels_u res_height
The height of the resolution of the image.
pixels_t x
The x coordinate of the pixel within the image.
pixels_u res_width
The width of the resolution of the image.
pixels_t y
The y coordinate of the pixel within the image.
A coordinate that is relative to some other coordinate.
degrees_d direction
The heading towards the coordinate.
millimetres_u distance
The distance to the coordinate.