Skip to content

[ISSUE #17] Corrected the angle functions to fix the incorrected results strans function according to the documentation. #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PGSPHERE_VERSION = 1.2.2
PGSPHERE_VERSION = 1.2.3
EXTENSION = pg_sphere
RELEASE_SQL = $(EXTENSION)--$(PGSPHERE_VERSION).sql
USE_PGXS = 1
Expand Down Expand Up @@ -26,7 +26,8 @@ DATA_built = $(RELEASE_SQL) \
pg_sphere--1.1.5beta2gavo--1.1.5beta4gavo.sql \
pg_sphere--1.1.5beta4gavo--1.2.0.sql \
pg_sphere--1.2.0--1.2.1.sql \
pg_sphere--1.2.1--1.2.2.sql
pg_sphere--1.2.1--1.2.2.sql \
pg_sphere--1.2.2--1.2.3.sql

DOCS = README.pg_sphere COPYRIGHT.pg_sphere
REGRESS = init tables points euler circle line ellipse poly path box index \
Expand Down Expand Up @@ -256,6 +257,9 @@ pg_sphere--1.2.1--1.2.2.sql:
cat upgrade_scripts/[email protected] > $@
endif

pg_sphere--1.2.2--1.2.3.sql:
cat upgrade_scripts/[email protected] > $@

# end of local stuff

src/sscan.o : src/sparse.c
Expand Down
138 changes: 138 additions & 0 deletions expected/euler.out
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,141 @@ SELECT strans '-40d,0d,40d,ZZZ' <> '-40d,0d,40d,XXX' ;
f
(1 row)

SELECT strans ( 20.0*pi()/180.0, -270.0*pi()/180.0, 70.5*pi()/180.0, 'XZY' );
strans
---------------------------------------
0.34906585, 1.5707963, 1.2304571, XZY
(1 row)

SELECT theta( strans ( 20.0*pi()/180.0, -270.0*pi()/180.0, 70.5*pi()/180.0, 'XZY' ) );
theta
---------------
1.57079632679
(1 row)

SELECT psi( strans ( 20.0*pi()/180.0, -270.0*pi()/180.0, 70.5*pi()/180.0, 'XZY' ) );
psi
---------------
1.23045712266
(1 row)

SELECT phi( strans ( 20.0*pi()/180.0, -270.0*pi()/180.0, 70.5*pi()/180.0, 'XZY' ) );
phi
----------------
0.349065850399
(1 row)

SELECT theta( strans( '20d, 30d, 40d, XZY' ) );
theta
----------------
0.523598775598
(1 row)

SELECT psi( strans( '20d, 30d, 40d, XZY' ) );
psi
----------------
0.698131700798
(1 row)

SELECT phi( strans( '20d, 30d, 40d, XZY' ) );
phi
----------------
0.349065850399
(1 row)

SELECT strans( '2d 20m, 10d, 0' );
strans
---------------------------------
0.040724349, 0.17453293, 0, ZXZ
(1 row)

SELECT theta( strans( '2d 20m, 10d, 0' ) );
theta
----------------
0.174532925199
(1 row)

SELECT psi( strans( '2d 20m, 10d, 0' ) );
psi
-----
0
(1 row)

SELECT phi( strans( '2d 20m, 10d, 0' ) );
phi
-----------------
0.0407243492132
(1 row)

SELECT strans ( '10d, 90d, 270d, ZXZ' );
strans
--------------------------------------
0.17453293, 1.5707963, 4.712389, ZXZ
(1 row)

SELECT theta( strans ( '10d, 90d, 270d, ZXZ' ) );
theta
---------------
1.57079632679
(1 row)

SELECT psi( strans ( '10d, 90d, 270d, ZXZ' ) );
psi
---------------
4.71238898038
(1 row)

SELECT phi( strans ( '10d, 90d, 270d, ZXZ' ) );
phi
----------------
0.174532925199
(1 row)

SELECT - strans ( '20d, 50d, 80d, XYZ' );
?column?
--------------------------------------
4.8869219, 5.4105207, 5.9341195, ZYX
(1 row)

SELECT theta( - strans ( '20d, 50d, 80d, XYZ' ) );
theta
-----------------
-0.872664625997
(1 row)

SELECT psi( - strans ( '20d, 50d, 80d, XYZ' ) );
psi
-----------------
-0.349065850399
(1 row)

SELECT phi( - strans ( '20d, 50d, 80d, XYZ' ) );
phi
---------------
-1.3962634016
(1 row)

SELECT strans( '90d, 60d, 30d' );
strans
---------------------------------------
1.5707963, 1.0471976, 0.52359878, ZXZ
(1 row)

SELECT theta( strans( '90d, 60d, 30d' ) );
theta
--------------
1.0471975512
(1 row)

SELECT psi( strans( '90d, 60d, 30d' ) );
psi
----------------
0.523598775598
(1 row)

SELECT phi( strans( '90d, 60d, 30d' ) );
phi
---------------
1.57079632679
(1 row)

2 changes: 1 addition & 1 deletion expected/init.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ CREATE EXTENSION pg_sphere;
select pg_sphere_version();
pg_sphere_version
-------------------
1.2.2
1.2.3
(1 row)

2 changes: 0 additions & 2 deletions pg_sphere--1.2.2.sql.in

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion pg_sphere.control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# pg_sphere extension
comment = 'spherical objects with useful functions, operators and index support'
default_version = '1.2.2'
default_version = '1.2.3'
module_pathname = '$libdir/pg_sphere'
relocatable = true
46 changes: 46 additions & 0 deletions sql/euler.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,55 @@
\set ECHO none
SELECT set_sphere_output_precision(8);
SET extra_float_digits TO -3;
\set ECHO all

-- checking Euler transformation operators

SELECT strans '-10d,0d,10d,ZZZ' = '-10d,0d,10d,XXX' ;
SELECT strans '-40d,0d,40d,ZZZ' <> '-40d,0d,40d,XXX' ;

SELECT strans ( 20.0*pi()/180.0, -270.0*pi()/180.0, 70.5*pi()/180.0, 'XZY' );

SELECT theta( strans ( 20.0*pi()/180.0, -270.0*pi()/180.0, 70.5*pi()/180.0, 'XZY' ) );

SELECT psi( strans ( 20.0*pi()/180.0, -270.0*pi()/180.0, 70.5*pi()/180.0, 'XZY' ) );

SELECT phi( strans ( 20.0*pi()/180.0, -270.0*pi()/180.0, 70.5*pi()/180.0, 'XZY' ) );

SELECT theta( strans( '20d, 30d, 40d, XZY' ) );

SELECT psi( strans( '20d, 30d, 40d, XZY' ) );

SELECT phi( strans( '20d, 30d, 40d, XZY' ) );

SELECT strans( '2d 20m, 10d, 0' );

SELECT theta( strans( '2d 20m, 10d, 0' ) );

SELECT psi( strans( '2d 20m, 10d, 0' ) );

SELECT phi( strans( '2d 20m, 10d, 0' ) );

SELECT strans ( '10d, 90d, 270d, ZXZ' );

SELECT theta( strans ( '10d, 90d, 270d, ZXZ' ) );

SELECT psi( strans ( '10d, 90d, 270d, ZXZ' ) );

SELECT phi( strans ( '10d, 90d, 270d, ZXZ' ) );

SELECT - strans ( '20d, 50d, 80d, XYZ' );

SELECT theta( - strans ( '20d, 50d, 80d, XYZ' ) );

SELECT psi( - strans ( '20d, 50d, 80d, XYZ' ) );

SELECT phi( - strans ( '20d, 50d, 80d, XYZ' ) );

SELECT strans( '90d, 60d, 30d' );

SELECT theta( strans( '90d, 60d, 30d' ) );

SELECT psi( strans( '90d, 60d, 30d' ) );

SELECT phi( strans( '90d, 60d, 30d' ) );
7 changes: 3 additions & 4 deletions src/euler.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,23 +203,22 @@ spheretrans_phi(PG_FUNCTION_ARGS)
{
SEuler *se = (SEuler *) PG_GETARG_POINTER(0);

PG_RETURN_POINTER(&se->phi);
PG_RETURN_FLOAT8(se->phi);
}

Datum
spheretrans_theta(PG_FUNCTION_ARGS)
{
SEuler *se = (SEuler *) PG_GETARG_POINTER(0);

PG_RETURN_POINTER(&se->theta);
PG_RETURN_FLOAT8(se->theta);
}

Datum
spheretrans_psi(PG_FUNCTION_ARGS)
{
SEuler *se = (SEuler *) PG_GETARG_POINTER(0);

PG_RETURN_POINTER(&se->psi);
PG_RETURN_FLOAT8(se->psi);
}

Datum
Expand Down
1 change: 1 addition & 0 deletions upgrade_scripts/pg_sphere--1.2.2--1.2.3.sql.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- Nothing to upgrade in the schema