gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master 77833274 1/2: Library (arithmetic.h): box-arou


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 77833274 1/2: Library (arithmetic.h): box-around-ellipse accounts for floats
Date: Wed, 21 Dec 2022 11:32:22 -0500 (EST)

branch: master
commit 778332747020d389dcff57977ec2948de8350fd7
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    Library (arithmetic.h): box-around-ellipse accounts for floats
    
    Until now, the 'box-around-ellipse' operator would assume that the inputs
    are always double-precision floating point and would give segmentation
    faults for other types!
    
    With this commit, the condition that was causing this has been fixed. Also,
    the description of this operator in the book has claried that the two input
    lengths should be radius, not diameter for example.
---
 doc/gnuastro.texi | 4 ++--
 lib/arithmetic.c  | 6 ++----
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 1656de7d..aaa46bd5 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -18331,13 +18331,13 @@ The operators here describe certain functions that 
will be necessary when dealin
 @item box-around-ellipse
 Return the width (along horizontal) and height (along vertical) of a box that 
encompasses an ellipse with the same center point.
 The top-popped operand is assumed to be the position angle (angle from the 
horizontal axis) in @emph{degrees}.
-The second and third popped operands are the minor and major axis lengths 
respectively.
+The second and third popped operands are the minor and major radii of the 
ellipse respectively.
 This operator outputs two operands on the general stack.
 The first one is the width and the second (which will be the top one when this 
operator finishes) is the height.
 
 If the value to the second popped operand (minor axis) is larger than the 
third (major axis), a NaN value will be written for both the width and height 
of that element and a warning will be printed (the warning can be disabled with 
the @option{--quiet} option).
 
-As an example, if your ellipse has a major axis length of 10 units, a minor 
axis length of 4 units and a position angle of 20 degrees, you can estimate the 
bounding box with this command:
+As an example, if your ellipse has a major axis radius of 10 units, a minor 
axis radius of 4 units and a position angle of 20 degrees, you can estimate the 
bounding box with this command:
 
 @example
 $ echo "10 4 20" \
diff --git a/lib/arithmetic.c b/lib/arithmetic.c
index 90ce54ba..2842f745 100644
--- a/lib/arithmetic.c
+++ b/lib/arithmetic.c
@@ -2569,12 +2569,10 @@ arithmetic_box_around_ellipse(gal_data_t *d1, 
gal_data_t *d2,
   /* Convert the inputs into double. Note that if the user doesn't want to
      free the inputs, we should make a copy of 'a_data' and 'b_data'
      because the output will also be written in them. */
-  a_data=( ( d1->type==GAL_TYPE_FLOAT64
-             || flags & GAL_ARITHMETIC_FLAG_FREE )
+  a_data=( d1->type==GAL_TYPE_FLOAT64
            ? d1
            : gal_data_copy_to_new_type(d1, GAL_TYPE_FLOAT64) );
-  b_data=( ( d2->type==GAL_TYPE_FLOAT64
-             || flags & GAL_ARITHMETIC_FLAG_FREE )
+  b_data=( d2->type==GAL_TYPE_FLOAT64
            ? d2
            : gal_data_copy_to_new_type(d2, GAL_TYPE_FLOAT64) );
   pa_data=( d3->type==GAL_TYPE_FLOAT64



reply via email to

[Prev in Thread] Current Thread [Next in Thread]