LCOV - code coverage report
Current view: top level - pencil/include/geometry - geometry_point.inl (source / functions) Coverage Total Hit
Test: crystal-facet-uml_v1.63.2_covts Lines: 100.0 % 36 36
Test Date: 2025-05-01 10:10:14 Functions: 100.0 % 11 11

            Line data    Source code
       1              : /* File: geometry_point.inl; Copyright and License: see below */
       2              : 
       3              : #include "u8/u8_trace.h"
       4              : #include "u8/u8_log.h"
       5              : #include <assert.h>
       6              : #include <math.h>
       7              : 
       8           14 : static inline void geometry_point_init ( geometry_point_t *this_, double x, double y )
       9              : {
      10           14 :     (*this_).x = x;
      11           14 :     (*this_).y = y;
      12           14 : }
      13              : 
      14            2 : static inline geometry_point_t geometry_point_new ( double x, double y )
      15              : {
      16              :     geometry_point_t result;
      17            2 :     geometry_point_init( &result, x, y );
      18            2 :     return result;
      19              : }
      20              : 
      21              : static inline void geometry_point_reinit ( geometry_point_t *this_, double x, double y )
      22              : {
      23              :     (*this_).x = x;
      24              :     (*this_).y = y;
      25              : }
      26              : 
      27            1 : static inline void geometry_point_copy ( geometry_point_t *this_, const geometry_point_t *original )
      28              : {
      29            1 :     assert( NULL != original );
      30            1 :     (*this_) = (*original);
      31            1 : }
      32              : 
      33            1 : static inline void geometry_point_replace ( geometry_point_t *this_, const geometry_point_t *original )
      34              : {
      35            1 :     assert( NULL != original );
      36            1 :     (*this_) = (*original);
      37            1 : }
      38              : 
      39            5 : static inline void geometry_point_destroy ( geometry_point_t *this_ )
      40              : {
      41            5 : }
      42              : 
      43           67 : static inline double geometry_point_get_x ( const geometry_point_t *this_ )
      44              : {
      45           67 :     return (*this_).x;
      46              : }
      47              : 
      48           68 : static inline double geometry_point_get_y ( const geometry_point_t *this_ )
      49              : {
      50           68 :     return (*this_).y;
      51              : }
      52              : 
      53            1 : static inline double geometry_point_calc_chess_distance ( const geometry_point_t *this_, const geometry_point_t *that )
      54              : {
      55            1 :     assert( NULL != that );
      56            1 :     return ( fabs( (*this_).x - (*that).x ) + fabs( (*this_).y - (*that).y ) );
      57              : }
      58              : 
      59            1 : static inline bool geometry_point_equals ( const geometry_point_t *this_, const geometry_point_t *that )
      60              : {
      61            1 :     assert( NULL != that );
      62            1 :     return ( ( fabs( (*this_).x - (*that).x ) + fabs( (*this_).y - (*that).y ) ) < 0.000000001 );
      63              : }
      64              : 
      65            5 : static inline void geometry_point_shift ( geometry_point_t *this_, double delta_x, double delta_y )
      66              : {
      67            5 :     (*this_).x += delta_x;
      68            5 :     (*this_).y += delta_y;
      69            5 : }
      70              : 
      71            1 : static inline void geometry_point_trace ( const geometry_point_t *this_ )
      72              : {
      73            1 :     U8_TRACE_INFO( "geometry_point_t" );
      74            1 :     U8_TRACE_INFO_INT( "- x:", (*this_).x );
      75            1 :     U8_TRACE_INFO_INT( "- y:", (*this_).y );
      76            1 : }
      77              : 
      78              : 
      79              : /*
      80              : Copyright 2019-2025 Andreas Warnke
      81              : 
      82              : Licensed under the Apache License, Version 2.0 (the "License");
      83              : you may not use this file except in compliance with the License.
      84              : You may obtain a copy of the License at
      85              : 
      86              :     http://www.apache.org/licenses/LICENSE-2.0
      87              : 
      88              : Unless required by applicable law or agreed to in writing, software
      89              : distributed under the License is distributed on an "AS IS" BASIS,
      90              : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      91              : See the License for the specific language governing permissions and
      92              : limitations under the License.
      93              : */
        

Generated by: LCOV version 2.0-1