Thursday, March 17, 2011

Sampling data over a sine wave

Now here is something people may find useful, an equation for sampling a number distributed over a sine wave. It took me a couple of days to come up with this, but it seems to hold up.

SUM_point = SUM_total * sin(((180 / points_total) * point_sample) * (4*atan(1)/180)) / (points_total / 1.5708)

Basically I've found that if you add up the values of n points on a half circle, the sum is about 0.6365 times less than the number of points. Or points_total is 1.5708 times greater than their sum. Eg, 180 samples = 114.589. 720 samples = 458.265. 684000 samples = 435448. Divide any of these sampled by the sum and you get about 1.5708

And by going through this equation, you can add all SUM_point, and it will be about SUM_total. And by "about" I mean within a few hundredths depending on your precision with 1.5708. With 10 million sample points, Visual Studio gives me 1.5707963705064640.

So now you may be wondering what use this is? Well, say you want to find out how much the sun is irradiating a patch of ground at any given point throughout the day. And the only thing you have is the total energy irradiated. Well, over an ideal 12 hour period, from 6am (0 degrees) to 6pm (180 degrees), you can use this equation to calculate how much irradiation was received every hour. Or, every minute (12 hours * 60 minutes (720 sample points)), or even every second (12h * 60m * 60s (43200 sample points)... theoretically :) Because the sun isn't just shining on the patch of ground at a constant angle, it moves and gets stronger then weaker.

This may have limited uses, but if you're wanting to model the real world with some degree of accuracy, it's useful.

Sunday, March 13, 2011

XNA 4.0

I've finally taken the time to install XNA 4.0 and will be working on a new game idea. It will also give me a change to get the technical mind a workout as well. As a technical artist I find it important for me to keep both my technical and creative sides active to maximize my potential and keep me from getting bored. Woot :)