Debian Codegraph @

pencil/include/geometry/geometry_non_linear_scale.h

raw
1 /* File: geometry_non_linear_scale.h; Copyright and License: see below */
2
3 #ifndef GEOMETRY_NON_LINEAR_SCALE_H
4 #define GEOMETRY_NON_LINEAR_SCALE_H
5
6 /* public file for the doxygen documentation: */
7 /*!
8 * \file
9 * \brief Maps order-values to locations
10 */
11
12 #include "u8/u8_error.h"
13 #include <stdint.h>
14
15 /*!
16 * \brief constants of geometry_non_linear_scale_t
17 */
18 enum geometry_non_linear_scale_max_enum {
19 GEOMETRY_NON_LINEAR_SCALE_MAX_POINTS = 32, /*!< maximum number of points by which the non-linear scale function is defined */
20 };
21
22 /*!
23 * \brief attributes of a non_linear_scale
24 */
25 struct geometry_non_linear_scale_struct {
26 uint32_t num_points; /*!< number of valid elements in the arrays location and order */
27 double location[ GEOMETRY_NON_LINEAR_SCALE_MAX_POINTS ]; /*!< array containing locations for which an order is defined */
28 int32_t order[ GEOMETRY_NON_LINEAR_SCALE_MAX_POINTS ]; /*!< array containing order-values which correspond to a location */
29 };
30
31 typedef struct geometry_non_linear_scale_struct geometry_non_linear_scale_t;
32
33 /*!
34 * \brief initializes the geometry_non_linear_scale_t struct
35 *
36 * \param this_ pointer to own object attributes
37 * \param lower_bound lower bound location, defines the lowest location value
38 * \param upper_bound upper bound location, defines the upper-most location value
39 */
40 void geometry_non_linear_scale_init ( geometry_non_linear_scale_t *this_, double lower_bound, double upper_bound );
41
42 /*!
43 * \brief re-initializes the geometry_non_linear_scale_t struct
44 *
45 * \param this_ pointer to own object attributes
46 * \param lower_bound lower bound location, defines the lowest location value
47 * \param upper_bound upper bound location, defines the upper-most location value
48 */
49 static inline void geometry_non_linear_scale_reinit ( geometry_non_linear_scale_t *this_, double lower_bound, double upper_bound );
50
51 /*!
52 * \brief destroys the geometry_non_linear_scale_t struct
53 *
54 * \param this_ pointer to own object attributes
55 */
56 static inline void geometry_non_linear_scale_destroy ( geometry_non_linear_scale_t *this_ );
57
58 /*!
59 * \brief prints the geometry_non_linear_scale_t struct to the trace output
60 *
61 * \param this_ pointer to own object attributes
62 */
63 void geometry_non_linear_scale_trace ( const geometry_non_linear_scale_t *this_ );
64
65 /*!
66 * \brief adds an order-value to the non-linear scale, updates the locations of all defined points
67 *
68 * \param this_ pointer to own object attributes
69 * \param order order value for which a location shall be inserted to the scale
70 * \return U8_ERROR_ARRAY_BUFFER_EXCEEDED if buffer for points exceeded, U8_ERROR_NONE otherwise
71 */
72 u8_error_t geometry_non_linear_scale_add_order ( geometry_non_linear_scale_t *this_, int32_t order );
73
74 /*!
75 * \brief gets a location given an order-value
76 *
77 * \param this_ pointer to own object attributes
78 * \param order order value for which the location shall be determined
79 */
80 static inline double geometry_non_linear_scale_get_location ( const geometry_non_linear_scale_t *this_, int32_t order );
81
82 /*!
83 * \brief gets an order-value given a location
84 *
85 * \param this_ pointer to own object attributes
86 * \param location location for which the order shall be determined
87 * \param snap_interval maximum distance from location to next point which snaps the location to the points location.
88 * There is no snap mechanism to the borders INT32_MIN and INT32_MAX.
89 */
90 static inline int32_t geometry_non_linear_scale_get_order ( const geometry_non_linear_scale_t *this_, double location, double snap_interval );
91
92 /*!
93 * \brief checks if the given order is on grid
94 *
95 * \param this_ pointer to own object attributes
96 * \param order order value
97 * \return true if order is on grid; the borders INT32_MIN and INT32_MAX are not on grid.
98 */
99 static inline bool geometry_non_linear_scale_is_order_on_grid ( const geometry_non_linear_scale_t *this_, int32_t order );
100
101 /*!
102 * \brief gets the interval count between the points.
103 *
104 * \param this_ pointer to own object attributes
105 * \return (*this_).num_points - 1
106 */
107 static inline uint32_t geometry_non_linear_scale_get_grid_intervals ( const geometry_non_linear_scale_t *this_ );
108
109 /*!
110 * \brief determines the average distance between grid points
111 *
112 * \param this_ pointer to own object attributes
113 * \return (upper_bound-lower_bound)/(*this_).num_points
114 */
115 static inline double geometry_non_linear_scale_get_grid_distances ( const geometry_non_linear_scale_t *this_ );
116
117 #include "geometry/geometry_non_linear_scale.inl"
118
119 #endif /* GEOMETRY_NON_LINEAR_SCALE_H */
120
121
122 /*
123 Copyright 2016-2026 Andreas Warnke
124
125 Licensed under the Apache License, Version 2.0 (the "License");
126 you may not use this file except in compliance with the License.
127 You may obtain a copy of the License at
128
129 http://www.apache.org/licenses/LICENSE-2.0
130
131 Unless required by applicable law or agreed to in writing, software
132 distributed under the License is distributed on an "AS IS" BASIS,
133 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
134 See the License for the specific language governing permissions and
135 limitations under the License.
136 */