|
In lugnet.org.ca.rtltoronto, Rob Antonishen <rob.antonishen@gmail.com> wrote:
>
> The problem is that the direction 0 degrees and 360 degrees are the
> same (North). Let's say that the wind is from the north; if I have
> e.g. 4 samples and half of them are 350 degrees and the other half are
> 10 degrees the mathematical average is (10+10+350+350) / 4 = 180
> degrees! This is mathematically right result but it should be 0.
>
> Similarly, taking a 360 modulus before dividing but this fails too.
> For example ((100+100+100+100) modulo 360) / 4 = 10 (incorrect, should
> be 100).
>
> Using trig, for each value accumulate the sum of the sines and the sum
> of the cosines. Then divide each of these sums by the number of
> entries to get:
> x = average cosine and y = average sine. Then use the arctan2 function
> to get the average angle as: Angle = arctan2( x , y), except this
> fails if x=0 and y=0, as would be the case when trying to average 90
> and 270, sot here is no simple solution to that problem with trig...
If I remember right, the way we resolved this for real-world surveying problems
and the like was to convert the degrees 180 < x < 360 into negative values
relative to 0/north. 350 is -10, 270 is -90, etc.
If x1 > 180
then x2 = 360 - x1
This makes your numbers relative to 0. You can then convert back if the average
is a negative number:
If avg1 < 0
then avg2 = 360 + avg1
-nk
|
|
Message has 1 Reply: | | Re: OT: Math Help
|
| (...) Don't you get the same problem at 180, now? 170 + 190 = 170 +(-170) = 0 I think there are several readings that can give you more than one result. For example, if you take two readings of 90 and 270, what should the answer be? 0? 180? never (...) (19 years ago, 5-Aug-05, to lugnet.org.ca.rtltoronto)
|
Message is in Reply To:
| | OT: Math Help
|
| Figured I'd bounce this problem off the smart people in RTLTotonto...This was posted on an automation mailing list, with little resolution: I have a weather station which measures both the direction and speed of the wind and is connected to a PC to (...) (19 years ago, 5-Aug-05, to lugnet.org.ca.rtltoronto)
|
9 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|