This repository has been archived on 2024-01-28. You can view files and clone it, but cannot push or open issues or pull requests.
ecg-prog-filtered/u02/include/util.h

33 lines
1.4 KiB
C
Raw Normal View History

// SPDX-License-Identifier: LGPL-3.0-or-later
#pragma once
#include <cstdint>
#include <tuple>
typedef uint8_t Transformation;
const Transformation TRANSFORM_MIRROR_X = 1 << 0;
const Transformation TRANSFORM_MIRROR_Y = 1 << 1;
const Transformation TRANSFORM_ROTATE_CW = 1 << 2;
const Transformation TRANSFORM_ROTATE_CCW = 1 << 3;
// Applies the provided transformation to the point, mutating it in place.
// Rotation is done before mirroring.
void transform_mut(Transformation transformation, int &x, int &y);
// Applies the provided transformation to the point,
// returning the transformed point.
// Rotation is done before mirroring.
std::pair<int, int> transform(Transformation transformation, int x, int y);
// Applies the inverse transformation to the point, mutating it in place.
// Composition of this with the transformation is the identity function.
void transform_inv_mut(Transformation transformation, int &x, int &y);
// Applies the inverse transformation to the point,
// returning the transformed point.
// Composition of this with the transformation is the identity function.
std::pair<int, int> transform_inv(Transformation transformation, int x, int y);
// Returns the transformation required
// to make the given endpoints of a line conform
// to the standard case for rasterization.
Transformation transformation_to_standard_case(int x0, int y0, int x1, int y1);