Skip to content

Commit

Permalink
Merge pull request #6 from OpenSmock/dev-pla
Browse files Browse the repository at this point in the history
Add convertion tools for angle : azimuth and trigonometric conversion…
  • Loading branch information
labordep committed Sep 19, 2024
2 parents 9ab22e3 + 6e0cfe4 commit d716dd2
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 1 deletion.
25 changes: 25 additions & 0 deletions GeoTools-Tests/GeoToolsExtensionsTests.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Class {
#name : #GeoToolsExtensionsTests,
#superclass : #TestCase,
#category : #'GeoTools-Tests'
}

{ #category : #'as yet unclassified' }
GeoToolsExtensionsTests >> testAsAzimuthAngle [

self assert: 0 asAzimuthAngle equals: 90.
self assert: 90 asAzimuthAngle equals: 0.
self assert: 180 asAzimuthAngle equals: 270.
self assert: 270 asAzimuthAngle equals: 180.
self assert: 360 asAzimuthAngle equals: 90.
]

{ #category : #'as yet unclassified' }
GeoToolsExtensionsTests >> testAsTrigonometricAngle [

self assert: 0 asTrigonometricAngle equals: 270.
self assert: 90 asTrigonometricAngle equals: 0.
self assert: 180 asTrigonometricAngle equals: 90.
self assert: 270 asTrigonometricAngle equals: 180.
self assert: 360 asTrigonometricAngle equals: 270.
]
45 changes: 44 additions & 1 deletion GeoTools-Tests/GeodesicUtilitiesTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,37 @@ GeodesicUtilitiesTest >> testCheckAngleIsBetweenTwoOthers [
]

{ #category : #tests }
GeodesicUtilitiesTest >> testConvertGeodesicToAzimuthInRadiansFromTwoPoints [
GeodesicUtilitiesTest >> testConvertGeodesicToAzimuthInRadiansFromTo [

| from to angleInRadians |

from := AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: 0.
to := AbsoluteCoordinates latitudeInDegrees: 10 longitudeInDegrees: 0.

angleInRadians := GeodesicUtilities convertGeodesicToAzimuthInRadiansFrom: from to: to.
self assert: (angleInRadians radiansToDegrees closeTo: 0 precision: 1e-10).

from := AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: 0.
to := AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: 10.

angleInRadians := GeodesicUtilities convertGeodesicToAzimuthInRadiansFrom: from to: to.
self assert: (angleInRadians radiansToDegrees closeTo: 90 precision: 1e-10).

from := AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: 0.
to := AbsoluteCoordinates latitudeInDegrees: -10 longitudeInDegrees: 0.

angleInRadians := GeodesicUtilities convertGeodesicToAzimuthInRadiansFrom: from to: to.
self assert: (angleInRadians radiansToDegrees closeTo: 180 precision: 1e-10).

from := AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: 0.
to := AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: -10.

angleInRadians := GeodesicUtilities convertGeodesicToAzimuthInRadiansFrom: from to: to.
self assert: (angleInRadians radiansToDegrees closeTo: 270 precision: 1e-10).
]

{ #category : #tests }
GeodesicUtilitiesTest >> testConvertGeodesicToAzimuthInRadiansFromTo2 [

| originPointAbsCoord endPointAbsCoord azRad|

Expand All @@ -61,6 +91,19 @@ GeodesicUtilitiesTest >> testConvertGeodesicToAzimuthInRadiansFromTwoPoints [
self assert: (azRad radiansToDegrees closeTo: 76.42078534394 precision: 1e-10) equals: true.
]

{ #category : #tests }
GeodesicUtilitiesTest >> testConvertGeodesicToAzimuthInRadiansFromTo3 [

| originPointAbsCoord endPointAbsCoord azRad|

originPointAbsCoord := AbsoluteCoordinates latitudeInDegrees: 48 longitudeInDegrees: -4.
endPointAbsCoord := AbsoluteCoordinates latitudeInDegrees: 48 longitudeInDegrees: 4.

azRad := GeodesicUtilities convertGeodesicToAzimuthInRadiansFrom: originPointAbsCoord to: endPointAbsCoord.
self assert: (azRad radiansToDegrees closeTo: 87.03 precision: 1e-2) equals: true.

]

{ #category : #tests }
GeodesicUtilitiesTest >> testConvertGeodesicToDistanceFromTwoPoints [

Expand Down
8 changes: 8 additions & 0 deletions GeoTools/CartesianCoordinates.class.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
"
I am Cartesian Coordinates.
The geocentric coordinate system is a geographic coordinate system in which the Earth is modeled as an ellipsoid in a right-handed XYZ (3D Cartesian) system, measured from the center of the Earth. In this system:
- X points towards the prime meridian
- Y points to 90° outside of the equatorial plane
- Z points in the direction of the North Pole.
It is important to note that the geocentric coordinate system is not a planar coordinate system based on a map projection. It is used internally as a transient system, serving as a computational framework in several geographical transformation methods.
"
Class {
#name : #CartesianCoordinates,
Expand Down
13 changes: 13 additions & 0 deletions GeoTools/Number.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Extension { #name : #Number }

{ #category : #'*GeoTools' }
Number >> asAzimuthAngle [

^ 90 - self \\ 360
]

{ #category : #'*GeoTools' }
Number >> asTrigonometricAngle [

^ self + 270 \\ 360
]

0 comments on commit d716dd2

Please sign in to comment.