TranceAddict Forums (www.tranceaddict.com/forums)
- Chill Out Room
-- Math help!!!
Pages (2): [1] 2 »
Math help!!!
I need to get the average of a set of angles...
angles = [355, 358, 0, 5, 351];
So I basically convert those numbers into radians.
Then I go through the radians and I convert them to their sine and cosine values and add those up.
I then get the average (totalSine/5) and (totalCosine/5)...
I then use atan2 to convert the averages back into an angle...
It doesn't work. I have mixed and matched values all over the place...
I get weird ass fucking numbers, like I give it two or three of the same number and I get back like 6.124125 or some really odd number.
I looked at this post: http://www.bio.net/bionet/mm/molmod...ary/000853.html
and...
this one I started off with and got those numbers to test: http://positivelyglorious.com/softw...es-of-azimuths/
Any ideas?
to put it simple
It's been a while since I did geometry, so could you explain why
(355 + 358 + 0 + 5 + 351) / 5 wouldn't work?
The average of a 30 degree and a 60 degree angle is 45, isn't it?
quote: |
Originally posted by basd It's been a while since I did geometry, so could you explain why (355 + 358 + 0 + 5 + 351) / 5 wouldn't work? The average of a 30 degree and a 60 degree angle is 45, isn't it? |
-2.2 °
Re: Math help!!!
quote: |
Originally posted by Joss Weatherby Then I go through the radians and I convert them to their sine and cosine values and add those up. |
quote: |
Originally posted by Joss Weatherby Think about a compass, you have to account for the fact that as value goes 0 is closer to 358 than 355. |
i think he's looking for a way to do this on c/c++
something like
x = y = 0
foreach angle {
x += cos(angle)
y += sin(angle)
}
average_angle = atan2(y, x)
just a guess.
quote: |
Originally posted by winston i think he's looking for a way to do this on c/c++ |
just create unit vectors for each of your angles and sum them.....
This is why you want to go to school instead of being a bum
do it in java
public class AvgAngles {
void print()
{
System.out.println(-5+-2+0+5-9/11);
}
public static void main(String[] args) {
AvgAngles calc=new AvgAngles();
calc.print();
}
}
all this -5 stuff is great but where do i start making them negatives, this is an arbitrary list of values, not something i have defined.
Winston I tried that but I keep getting fucked up values, should they be radians when getting there sine and cosine values?
use constructors? this is in java.
public class AvgAngles{
int a;
int b;
int....etc;
public AvgAngles (int x, int y....etc)
{
a=x;
b=y;
)
void run()
{
System.out.println(a+b+..../5)
}
public static void main (String[] args)
{
AvgAngles calc=new AvgAngles(first value, second value) //these parameters are to be passed to the constructor
calc.run();
}
}
you can change all the ints to float or double if you want
quote: |
Originally posted by TranceOwnsLol use constructors? this is in java. public class AvgAngles{ int a; int b; int....etc; public AvgAngles (int x, int y....etc) { a=x; b=y; ) void run() { System.out.println(a+b+..../5) } public static void main (String[] args) { AvgAngles calc=new AvgAngles(first value, second value) //these parameters are to be passed to the constructor calc.run(); } } you can change all the ints to float or double if you want |
quote: |
Originally posted by Joss Weatherby I need to get the average of a set of angles... angles = [355, 358, 0, 5, 351]; So I basically convert those numbers into radians. Then I go through the radians and I convert them to their sine and cosine values and add those up. I then get the average (totalSine/5) and (totalCosine/5)... I then use atan2 to convert the averages back into an angle... It doesn't work. ![]() I get weird ass fucking numbers, like I give it two or three of the same number and I get back like 6.124125 or some really odd number. I looked at this post: http://www.bio.net/bionet/mm/molmod...ary/000853.html and... this one I started off with and got those numbers to test: http://positivelyglorious.com/softw...es-of-azimuths/ Any ideas? |
quote: |
Originally posted by Joss Weatherby all this -5 stuff is great but where do i start making them negatives, this is an arbitrary list of values, not something i have defined. Winston I tried that but I keep getting fucked up values, should they be radians when getting there sine and cosine values? |
galileo galilei
Are you sure you're converting the output angle back to degrees?
Check that -- if that's not what's up, then post code.
wolframalpha?
Hey guys thanks for the help so far, I havent had a chance to test it yet, I have to write some stupid manual shit, but I plan to look at it ASAP.
Just use complex numbers surely? Been aggggeees since I've done this pish though.
dude who would come to the c0r for a math advice...
>Xplians<
Think if you have them in as engineers would call j notation (as above) you can pretty much just add them. Well like real + real, imaginary + imaginary.
I would help you but I don't feel like it.
quote: |
Originally posted by rT19 dude who would come to the c0r for a math advice... |
Powered by: vBulletin
Copyright © 2000-2021, Jelsoft Enterprises Ltd.