Skip to content

Commit

Permalink
Corrections method check azimuth towards area (+test)
Browse files Browse the repository at this point in the history
  • Loading branch information
LANDAISB committed Mar 1, 2024
1 parent bf4efdc commit 5068888
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 10 deletions.
26 changes: 23 additions & 3 deletions GeoView-Tests/GeodesicUtilitiesTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ GeodesicUtilitiesTest >> testIsAzimuthTowardsArea [
listPointsArea add: (AbsoluteCoordinates latitudeInDegrees: 48.3117 longitudeInDegrees: -4.60466).
listPointsArea add: (AbsoluteCoordinates latitudeInDegrees: 48.29603 longitudeInDegrees: -4.62295).

"headingInDegree := 45.
headingInDegree := 45.

isAzTowardsArea := GeodesicUtilities isAzimuthTowardsAreaFrom: originPointAbsCoord azimuth: headingInDegree area: listPointsArea.

Expand All @@ -74,14 +74,34 @@ GeodesicUtilitiesTest >> testIsAzimuthTowardsArea [

isAzTowardsArea := GeodesicUtilities isAzimuthTowardsAreaFrom: originPointAbsCoord azimuth: headingInDegree area: listPointsArea.

self assert: isAzTowardsArea equals: false."
originPointAbsCoord latitudeInDegrees: 48.29603.
self assert: isAzTowardsArea equals: false.

headingInDegree := 90.

isAzTowardsArea := GeodesicUtilities isAzimuthTowardsAreaFrom: originPointAbsCoord azimuth: headingInDegree area: listPointsArea.

self assert: isAzTowardsArea equals: true.

originPointAbsCoord := AbsoluteCoordinates latitudeInDegrees: 48.34 longitudeInDegrees: -4.62.
headingInDegree := 225.

isAzTowardsArea := GeodesicUtilities isAzimuthTowardsAreaFrom: originPointAbsCoord azimuth: headingInDegree area: listPointsArea.

self assert: isAzTowardsArea equals: true.

headingInDegree := 180.

isAzTowardsArea := GeodesicUtilities isAzimuthTowardsAreaFrom: originPointAbsCoord azimuth: headingInDegree area: listPointsArea.

self assert: isAzTowardsArea equals: true.

originPointAbsCoord := AbsoluteCoordinates latitudeInDegrees: 48.01 longitudeInDegrees: -4.62.
headingInDegree := 45.

isAzTowardsArea := GeodesicUtilities isAzimuthTowardsAreaFrom: originPointAbsCoord azimuth: headingInDegree area: listPointsArea.

self assert: isAzTowardsArea equals: false.



]
25 changes: 18 additions & 7 deletions GeoView/GeodesicUtilities.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,25 @@ GeodesicUtilities class >> isAzimuthTowardsAreaFrom: anAbsCoordOrigin azimuth: a
"Compute angles between origin position and vertices of area"
listAngles := (aListOfAbsoluteCoords collect: [ :absCoord |
self convertGeodesicToAzimuthInRadiansFrom: anAbsCoordOrigin to: absCoord ]
) asOrderedCollection.

listAngles := listAngles sort: [ :a :b | a < b ].

) asOrderedCollection.
listAngles add: listAngles first.

azRad := anAzimuthInDegree degreesToRadians.
isPointingArea := azRad between: listAngles first and: listAngles last.
isPointingArea := isPointingArea or:[ azRad closeTo: listAngles first precision: 1e-3 ].
isPointingArea := isPointingArea or:[ azRad closeTo: listAngles last precision: 1e-3 ].

isPointingArea := false.
listAngles withIndexDo:[:a :i | | nextAngle |
isPointingArea := isPointingArea or:[ azRad closeTo: a precision: 1e-3 ].

i < listAngles size ifTrue:[
nextAngle := listAngles at: i+1.
nextAngle - a <= Float pi ifTrue:[
isPointingArea := isPointingArea or:[ azRad between: a and: nextAngle ]
] ifFalse:[
isPointingArea := isPointingArea or:[ azRad between: nextAngle and: a ]
].
isPointingArea := isPointingArea or:[ azRad closeTo: nextAngle precision: 1e-3 ].
]
].

^ isPointingArea
]
Expand Down

0 comments on commit 5068888

Please sign in to comment.