| 1 |
/* File: geometry_offset.h; Copyright and License: see below */ |
| 2 |
|
| 3 |
#ifndef GEOMETRY_OFFSET_H |
| 4 |
#define GEOMETRY_OFFSET_H |
| 5 |
|
| 6 |
/* public file for the doxygen documentation: */ |
| 7 |
/*! |
| 8 |
* \file |
| 9 |
* \brief Stores an offset in a 2-dimensional space |
| 10 |
*/ |
| 11 |
|
| 12 |
#include <stdbool.h> |
| 13 |
|
| 14 |
/*! |
| 15 |
* \brief attributes of an offset |
| 16 |
*/ |
| 17 |
struct geometry_offset_struct { |
| 18 |
double dx; |
| 19 |
double dy; |
| 20 |
}; |
| 21 |
|
| 22 |
typedef struct geometry_offset_struct geometry_offset_t; |
| 23 |
|
| 24 |
/*! |
| 25 |
* \brief initializes the geometry_offset_t struct |
| 26 |
* |
| 27 |
* \param this_ pointer to own object attributes |
| 28 |
* \param dx x offset of the object |
| 29 |
* \param dy y offset of the object |
| 30 |
*/ |
| 31 |
static inline void geometry_offset_init ( geometry_offset_t *this_, double dx, double dy ); |
| 32 |
|
| 33 |
/*! |
| 34 |
* \brief initializes the geometry_offset_t struct |
| 35 |
* |
| 36 |
* \param dx x offset of the object |
| 37 |
* \param dy y offset of the object |
| 38 |
* \return the initialized offset |
| 39 |
*/ |
| 40 |
static inline geometry_offset_t geometry_offset_new ( double dx, double dy ); |
| 41 |
|
| 42 |
/*! |
| 43 |
* \brief re-initializes the geometry_offset_t struct |
| 44 |
* |
| 45 |
* \param this_ pointer to own object attributes |
| 46 |
* \param dx x offset of the object |
| 47 |
* \param dy y offset of the object |
| 48 |
*/ |
| 49 |
static inline void geometry_offset_reinit ( geometry_offset_t *this_, double dx, double dy ); |
| 50 |
|
| 51 |
/*! |
| 52 |
* \brief copies original to this uninitialized geometry_offset_t struct |
| 53 |
* |
| 54 |
* \param this_ pointer to own object attributes |
| 55 |
* \param original pointer to object attributes that shall be copied |
| 56 |
*/ |
| 57 |
static inline void geometry_offset_copy ( geometry_offset_t *this_, const geometry_offset_t *original ); |
| 58 |
|
| 59 |
/*! |
| 60 |
* \brief replaces the already initialized geometry_offset_t struct by other data |
| 61 |
* |
| 62 |
* \param this_ pointer to own object attributes |
| 63 |
* \param original pointer to object attributes that shall be copied |
| 64 |
*/ |
| 65 |
static inline void geometry_offset_replace ( geometry_offset_t *this_, const geometry_offset_t *original ); |
| 66 |
|
| 67 |
/*! |
| 68 |
* \brief destroys the geometry_offset_t struct |
| 69 |
* |
| 70 |
* \param this_ pointer to own object attributes |
| 71 |
*/ |
| 72 |
static inline void geometry_offset_destroy ( geometry_offset_t *this_ ); |
| 73 |
|
| 74 |
/*! |
| 75 |
* \brief gets the x offset of geometry_offset_t |
| 76 |
* |
| 77 |
* \param this_ pointer to own object attributes |
| 78 |
*/ |
| 79 |
static inline double geometry_offset_get_dx ( const geometry_offset_t *this_ ); |
| 80 |
|
| 81 |
/*! |
| 82 |
* \brief gets the y offset of geometry_offset_t |
| 83 |
* |
| 84 |
* \param this_ pointer to own object attributes |
| 85 |
*/ |
| 86 |
static inline double geometry_offset_get_dy ( const geometry_offset_t *this_ ); |
| 87 |
|
| 88 |
/*! |
| 89 |
* \brief determines if the two geometry_offset_t refer to the same location |
| 90 |
* |
| 91 |
* \param this_ pointer to own object attributes |
| 92 |
* \param that pointer to other object attributes |
| 93 |
* \return true if the two points are equal |
| 94 |
*/ |
| 95 |
static inline bool geometry_offset_equals ( const geometry_offset_t *this_, const geometry_offset_t *that ); |
| 96 |
|
| 97 |
/*! |
| 98 |
* \brief gets the direction of *this_ offset. |
| 99 |
* |
| 100 |
* Negative dy values mean GEOMETRY_DIRECTION_UP, negative dx values mean GEOMETRY_DIRECTION_LEFT. GEOMETRY_DIRECTION_CENTER if offset is zero. |
| 101 |
* |
| 102 |
* \param this_ pointer to own object attributes |
| 103 |
* \return direction of the offset |
| 104 |
*/ |
| 105 |
static inline geometry_direction_t geometry_offset_get_direction ( const geometry_offset_t *this_ ); |
| 106 |
|
| 107 |
/*! |
| 108 |
* \brief prints the geometry_offset_t struct to the trace output |
| 109 |
* |
| 110 |
* \param this_ pointer to own object attributes |
| 111 |
*/ |
| 112 |
static inline void geometry_offset_trace ( const geometry_offset_t *this_ ); |
| 113 |
|
| 114 |
#include "geometry/geometry_offset.inl" |
| 115 |
|
| 116 |
#endif /* GEOMETRY_OFFSET_H */ |
| 117 |
|
| 118 |
|
| 119 |
/* |
| 120 |
Copyright 2025-2026 Andreas Warnke |
| 121 |
|
| 122 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 123 |
you may not use this file except in compliance with the License. |
| 124 |
You may obtain a copy of the License at |
| 125 |
|
| 126 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 127 |
|
| 128 |
Unless required by applicable law or agreed to in writing, software |
| 129 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 130 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 131 |
See the License for the specific language governing permissions and |
| 132 |
limitations under the License. |
| 133 |
*/ |