Is there an existing algorithm for converting a quaternion representation of a rotation to an Euler angle representation? The rotation order for the Euler representation is known and can be any of the six permutations (i.e. xyz, xzy, yxz, yzx, zxy, zyx). I've seen algorithms for a fixed rotation order (usually the NASA heading, bank, rol...
For a library, I need to store the first primes numbers up to a limit L. This collection must have a O(1) lookup time (to check whether a number is prime or not) and it must be easy, given a number, to find the next prime number (assuming it is smaller than L).
Given that L is fixed, an Eratostene sieve to generate the list is fine. Rig...
I would like to have something that looks something like this. Two different colors are not nessesary.
I already have the audio data (one sample/millisecond) from a stereo wav in two int arrays, one each for left and right channel. I have made a few attempts but they don't look anywhere near as clear as this, my attempts get to spikey...
The user wants to impose a unique, non-trivial, upper/lower bound on the correlation between every pair of variable in a var/covar matrix.
For example: I want a variance matrix in which all variables have 0.9 > |rho(x_i,x_j)| > 0.6, rho(x_i,x_j) being the correlation between variables x_i and x_j.
Thanks.
...
The user wants to impose a unique, non-trivial, upper/lower bound on the correlation between every pair of variable in a var/covar matrix.
For example: I want a variance matrix in which all variables have 0.9 > |rho(x_i,x_j)| > 0.6, rho(x_i,x_j) being the correlation between variables x_i and x_j.
Thanks.
Ok, something of a quick&di...
At present I have a control to which I need to add the facility to apply various acuteness (or sensitivity). The problem is best illustrated as an image:
As you can see, I have X and Y axess that both have arbitrary limits of 100 - that should suffice for this explanation. At present, my control is the red line (linear behaviour), but...
I'm looking form a programatic way to take an integer sequence and spit out a closed form function. Something like:
Given: 1,3,6,10,15
Return: n(n+1)/2
Samples could be useful; the language is unimportant.
...
Is there a function which will return the approximate value of the n th prime? I think this would be something like an approximate inverse prime counting function. For example, if I gave this function 25 it would return a number around 100, or if I gave this function 1000 it would return a number around 8000. I don't care if the number r...
There are two sorts of TV: Traditional ones that have an aspect ratio of 4:3 and wide screen ones that are 16:9. I am trying to write a function that given the diagonal of a 16:9 TV gives the diagonal of a 4:3 TV with the equivalent height. I know that you can use Pythagoras' theorem to work this out if I know two of the sides, but I onl...
In C the atan2 function has the following signature:
double atan2( double y, double x );
Other languages do this as well. This is the only function I know of that takes its arguments in Y,X order rather than X,Y order, and it screws me up regularly because when I think coordinates, I think (X,Y).
Does anyone know why atan2's argumen...
What i am really looking for is a maths equation function that takes in a string representing and equation and calculates the answer as a return type
For Example
"(((4 * 5) + 6) * 2) / 8"
OutPut: 6.5
So in coding tearms something like
print calc("(((4 * 5) + 6) * 2) / 8");
Is there already a class or a function that some angel has...
I have this bit of VB6 sliced out of a project I'm working on:
Public Function C_Ln(c As ComplexNumber) As ComplexNumber
Set C_Ln = toComplex(Log(C_Abs(c)), Atan2(c.Imag, c.Real))
End Function
The VB6 Log() function is base-e. I'd like to cook up versions of this to do base-2, base-10 and base-n. Where do I start?
...
I have three colors in an array, array('blue', 'red', 'green'), and in my loop, I want to be able to print blue, red, green, blue, red, green.
I know that I could just reset a counter every 3 loops, and use that to find the color I want - 1, 2, 3, reset, 1, 2, 3, reset, etc. But is there a simple way to pass it the current loop count, ...
I want to design a URL shortener for a particular use case and type of end-user that I have targetted. I have decided that I want the URLs to be stored internally according to an auto-incrementing integer key. However, it is also required that a key be represented to users in the url as six-digit base 26 (a-z * 6) AND it's not possible t...
I'm looking at some code which should be trivial -- but my math is failing me miserably here.
Here's a condition that checks if a number if a power of 2 using the following:
if((num != 1) && (num & (num - 1))) { /* make num pow of 2 */ }
My question is, how does using a bitwise AND between num and num - 1 determine if a number is a p...
How can I calculate a point (X,Y) a specified distance away, on a rotated axis? I know what angle I'd like the point "moving" along (in degrees).
...
I have quite an interesting task at work - I need to find out how much time user spent doing something and all I have is timestamps of his savings. I know for a fact that user saves after each small portion of a work, so they is not far apart.
The obvious solution would be to find out how much time one small item could possibly take and...
What should 'foo' be called, given the following?
x.items is a set, y.values is a set.
function a(key) returns an ordered list of x.items
function b(x.item) returns a single y.value
Define foo(a, b), which returns a function, d, such that d(key) returns a list of y.values defined by: map(b, a(key)).
This feels like a fairly common a...
Hello
I have an array of points. I want to know if this array of point represents a circle, a square or a triangle.
Where should i begin? (i use C#)
Thanks
Jon
...
Does such function exist? I created my own but would like to use an official one:
private function opposite(number:Number):Number
{
if (number < 0)
{
number = Math.abs(number);
}
else
{
number = -(number);
}
return number;
}
So, -5 becomes 5 and 3 becomes -3.
Edit:
For...